Skip to content

Instantly share code, notes, and snippets.

@GiacomoP
Created May 26, 2016 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GiacomoP/a9b7cf4691e76e998b67dfa9f37c3099 to your computer and use it in GitHub Desktop.
Save GiacomoP/a9b7cf4691e76e998b67dfa9f37c3099 to your computer and use it in GitHub Desktop.
Handy code to have a CSV file as an associative array
<?php
$rows = array_map('str_getcsv', file('filename.csv'));
array_walk($rows, function(&$a) use ($rows) {
$a = array_combine($rows[0], $a);
});
array_shift($rows);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment