Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP Preg_Match从字符串中提取逗号分隔的值_Php_Regex_String - Fatal编程技术网

PHP Preg_Match从字符串中提取逗号分隔的值

PHP Preg_Match从字符串中提取逗号分隔的值,php,regex,string,Php,Regex,String,可能重复: 我有一个字符串,看起来像:[something=“1,2,3”] 我需要把引号之间的所有内容都转换成字符串。我确信preg_match是实现这一点的方法,但我不确定要使用的表达式 $content = [something = "1,2,3"]; $new_string = preg_match('?regex?','$content'); 试试这个: $content = '[something = "1,2,3"]'; if (preg_match('/"([^"]+)"/

可能重复:

我有一个字符串,看起来像:
[something=“1,2,3”]
我需要把引号之间的所有内容都转换成字符串。我确信preg_match是实现这一点的方法,但我不确定要使用的表达式

$content = [something = "1,2,3"];
$new_string = preg_match('?regex?','$content');
试试这个:

$content = '[something = "1,2,3"]';

if (preg_match('/"([^"]+)"/', $content, $matches)) {
    $matchedContent = $matches[1];
}

非常感谢你的快速回答。很好!