Using: PHP 7
I need to parse a string from a CSV file and return the values in an array. I'm using preg_match_all, but have had no luck so far.
This is the string:
"494","1","41","2009-05-18","NULL","0","3","JONES,ZACK ZX",""
This is the PHP code:
<?php
$s = '"494","1","41","2009-05-18","NULL","0","3","JONES,ZACK ZX",""' ;
$p = '(?<=^|,)(?:[^,"]+|")?(?=,|$)|(?<=^|,)".*?"(?=,|$)';
$m = Array();
$e = preg_match_all($p, $s, $m);
After it is executed, the $m array should contain all the string values, without the double-quote string enclosure character.
Would appreciate any help in getting the correct regular expression to use.
str_getcsv?