Forget this while() loop mumbo jumbo! Use this:
$rows = array_map('str_getcsv', file('myfile.csv'));
$header = array_shift($rows);
$csv = array();
foreach ($rows as $row) {
$csv[] = array_combine($header, $row);
}
Source: https://steindom.com/articles/shortest-php-code-convert-csv-associative-array