Thursday, May 28, 2015

CSV file to PHP array

Here is a pretty cool snippet to read csv file and turn it into a php array:

function read_csv($csv_path){
$file = fopen($csv_path, 'r');
while (!feof($file) ) {
$lines[] = fgetcsv($file);
}
fclose($file);
return $lines;
}