こんにちは、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
)
しかし、私はまた、空白のものを返して助けてほしい.