I need split string by comma, but comma shouldn`t be inside square brackets. For example string:
'"f2140202585",true,"some, str","numeric","MegapixNum","","","0.3,16.0","0.3,16","17",2,""'
Should produce this result:
['"f2140202585"', 'true', '"some, str"', '"numeric"', '"MegapixNum"', '"0.3,16.0"', '"0.3,16"', '"17"', '2', '""']
I know that preg_replace function exists for this, but i cant figure out what regexp should be.
I solve it this way:
preg_match_all('/("[^"]+?"|[^\,]+)/', $faq, $matches);