It drives me crazy ... I try to parse a csv file and there is a very strange behavior.
Here is the csv
action;id;nom;sites;heures;jours i;;\"un nom a
Probably there is some special character at the beginning of the first line and trim isn't removing it.
trim
Try to remove every non-word character this way:
// Identify headers if(!isset($headers)) { for($i=0;$i<$cols;$i++) { $headers[preg_replace("/[^\w\d]/","",strtolower($row[$i]))] = $i; ....