Created
May 5, 2017 09:57
-
-
Save adeel-raza/589797fbcf4cfd7fa7289540b7918f40 to your computer and use it in GitHub Desktop.
Parse a CSV as an associate array with column names as keys and row as values
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
$csv = array_map("str_getcsv", file("file1.csv",FILE_SKIP_EMPTY_LINES)); | |
$keys = array_shift($csv); | |
foreach ($csv as $i=>$row) { | |
$csv[$i] = array_combine($keys, $row); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment