Skip to content

Instantly share code, notes, and snippets.

@steffen-wirth
Created February 2, 2015 08:53
Show Gist options
  • Save steffen-wirth/31d06cd35684ee7336dd to your computer and use it in GitHub Desktop.
Save steffen-wirth/31d06cd35684ee7336dd to your computer and use it in GitHub Desktop.
csv table to array with column headers as keys
$all_rows = array();
$header = null;
while ($row = fgetcsv($file)) {
if ($header === null) {
$header = $row;
continue;
}
$all_rows[] = array_combine($header, $row);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment