read csv data php code example
Example 1: php read csv
<?php
ini_set('auto_detect_line_endings',TRUE);
$handle = fopen('/path/to/file','r');
while ( ($data = fgetcsv($handle) ) !== FALSE ) {
//process the array in $data
var_dump($data);
}
ini_set('auto_detect_line_endings',FALSE);
Example 2: php open csv
$csvFile = file('../somefile.csv');
$data = [];
foreach ($csvFile as $line) {
$data[] = str_getcsv($line);
}