Assigning array keys based on the values of another array
PHP provides functions to parse CSV files and strings line-by-line.

$file = ...
$headers = fgetcsv($file);
$lines = array();
while (($line = fgetcsv($file)) !== false) {
    $lines[] = array_combine($headers, $line);
}