Created
May 26, 2016 13:27
-
-
Save GiacomoP/a9b7cf4691e76e998b67dfa9f37c3099 to your computer and use it in GitHub Desktop.
Handy code to have a CSV file as an associative array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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