Page 1 of 1

Spliting from CSV

Posted: Mon Sep 27, 2010 12:05 am
by eyriquewong
hi,

i have a csv file, the data is something as below:
1/19/2010,book_1,14,"67,333",5
2/19/2010,book_2,15,"15,123",6
how do i make it into an array?

Here's how i come so far
$temp_array = explode("\n",read_file('my.csv'));
foreach($temp_array as $lines){
//echo $lines;
list($date,$booktitle,$id,$total_hits,$price) = explode($lines);
}
But it seems that it had split the hits comma value as well... is there any way to ignore the comma inside a double quote?

Thanks

Re: Spliting from CSV

Posted: Mon Sep 27, 2010 12:20 am
by requinix
fopen + fgetcsv in a loop + fclose.