Created
October 2, 2015 22:55
-
-
Save rcknr/71b1ae32a40dfa29bdca to your computer and use it in GitHub Desktop.
Convert a CSV file to an associative array
This file contains hidden or 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 | |
$source = file('http://example.com/example.csv'); | |
$csv_array = array_map('str_getcsv', $source, array_fill(0, count($source), ';')); | |
$header = array_shift($csv_array); | |
$result = array_map('array_combine', array_fill(0, count($csv_array), $header), $csv_array); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment