Skip to content

Instantly share code, notes, and snippets.

@wjgilmore
Created January 19, 2012 13:39
Show Gist options
  • Save wjgilmore/1640085 to your computer and use it in GitHub Desktop.
Save wjgilmore/1640085 to your computer and use it in GitHub Desktop.
Convert two column csv file to an associative array
<?php
$csvFile = "file.csv";
if (($handle = fopen($csvFile, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
printf("'%s' => '%s',\n", $data[0], $data[1]);
}
fclose($handle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment