CSV import via PHP -
i'm importing .csv application following:
if (($handle = fopen($file, "r")) !== false) { while (($data = fgetcsv($handle, 1000, ",")) !== false) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n"; } } fclose($handle); }
it sort of works it's far perfect. wanted first out row heads , put them array , loop round each row data sets in.
it seems having delimitting problems first row (heads) including few parts of second row.
i exported .csv file straight excel. wonder if there encoding tricks etc might missing.
fgetcsv
doesnt detect line endings.
try using before fgetcsv call:
ini_set('auto_detect_line_endings', true);
Comments
Post a Comment