php csv to array with header
function parse($file, $separ = ';')
{
$arrays = array_map(function ($foo) use ($separ) {
return array_map("trim", str_getcsv($foo, $separ));
}, file($file, FILE_SKIP_EMPTY_LINES));
$header = $arrays[0];
unset($arrays[0]);
$array_with_keys = [];
foreach ($arrays as $array) {
$_array = [];
foreach ($array as $key => $value) {
$_array[$header[$key]] = $value;
}
$array_with_keys[] = $_array;
}
return $array_with_keys;
}