Using Data from csv file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
h123z
Forum Newbie
Posts: 7
Joined: Tue Sep 18, 2007 5:18 am

Using Data from csv file

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

PHP has CSV specific file handling functions like fgetcsv() and fputcsv(). Have you messed with any of these?
Post Reply