Page 1 of 1

Using Data from csv file

Posted: Mon Oct 08, 2007 7:20 am
by h123z
How do I get data from a csv file, if the fields have commas in them?
right now, i have:
$sep=',';
list($col_1,$col_2) = explode($sep, $line);
but that splits up fields with commas
thanks

Posted: Mon Oct 08, 2007 10:35 am
by John Cartwright
Usually when a csv has a comma in the data itself, the field will be wrapped in quotes.

Can you post some sample data?

Posted: Mon Oct 08, 2007 11:41 am
by RobertGonzalez
PHP has CSV specific file handling functions like fgetcsv() and fputcsv(). Have you messed with any of these?