Normalizzare un CSV
function normalize_csv($content){
$rows = explode(PHP_EOL, $content);
$cols = [];
foreach ($rows as $key => $row) {
$cols[] = explode(';', $row);
}
return $cols;
}Headers?
function normalize_csv($file){
$rows = array_map('str_getcsv', file($file));
$header = array_shift($rows);
$csv = array();
foreach($rows as $row) {
$csv[] = array_combine($header, $row);
}
return $csv;
}PreviousOttenere l'url completo in PHPNextOrdinare un array multidimensionale per le chiavi del sottoarray
Last updated