嗨,我正在使用 Preg_match_all 函数遍历一个字符串并返回其值的数组。
$str = 'field1,field2,field3,field4,,,,,,,"some text, some other text",field6';
preg_match_all("~\"[^\"]++\"|[^,]++~", $str,$match);
echo "<pre>";
print_r($match[0]);
echo "<pre>";
它返回这个。
Array
(
[0] => field1
[1] => field2
[2] => field3
[3] => field4
[4] => "some text, some other text"
[5] => field6
)
但我也希望它返回空白以请帮助。