Revision: 15038
Updated Code
at June 22, 2009 07:05 by antpaw
Updated Code
<?php /* your CSV should look like this: data1;data2;data3; data1;data2124;data3; data1;data2564;data3; data1;data2321;data3; */ $fileCont = join('', file('myCSV.csv')); $fileArrN = explode("\n", $fileCont); $a = 0; foreach ($fileArrN as $value){ $fileArrSemi[$a] = explode(";", $value); $a++; } $output = null; for($i = 0; $i < sizeof($fileArrSemi); $i++){ $output .= $fileArrSemi[$i][1]."<br />\n"; } echo $output; ?>
Revision: 15037
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 22, 2009 07:04 by antpaw
Initial Code
<?php /* your CSV should look like this: data1;data2;data3; data1;data2124;data3; data1;data2564;data3; data1;data2321;data3; */ $fileCont = join('', file('myCSV.csv')); $fileArrN = explode("\n", $fileCont); $a = 0; foreach ($fileArrN as $value){ $fileArrSemi[$a] = explode(";", $value); $a++; } $output = null; for($i = 0; $i < sizeof($fileArrSemi); $i++){ $output .= $fileArrSemi[$i][1]."<br />\n"; } echo $output; ?>
Initial URL
Initial Description
this script splits the csv file two times (1. on "new line", 2. on ";") and returns a two dem array in the last for loop.
Initial Title
reading CSV file with PHP
Initial Tags
php, csv
Initial Language
PHP