Voting

: nine minus nine?
(Example: nine)

The Note You're Voting On

satyavvd at ymail dot com
13 years ago
Extract fields out of csv string : ( since before php5.3 you can't use str_getcsv function )
Here is the regex :

<?php

$csvData
= <<<EOF
10,'20',"30","'40","'50'","\"60","70,80","09\\/18,/\"2011",'a,sdfcd'
EOF

$reg = <<<EOF
/
(
(
([\'\"])
(
(
[^\'\"]
|
(\\\\.)
)*
)
(\\3)
|
(
[^,]
|
(\\\\.)
)*
),)
/x
EOF;

preg_match_all($reg,$csvData,$matches);

// to extract csv fields
print_r($matches[2]);
?>

<< Back to user notes page

To Top