Skip to content

Instantly share code, notes, and snippets.

@mhail
Created December 5, 2012 19:51
Show Gist options
  • Save mhail/4218905 to your computer and use it in GitHub Desktop.
Save mhail/4218905 to your computer and use it in GitHub Desktop.
PHP parse csv file
$line = 0; $header = array();
if (false !== ($handle = fopen($file_name, "r"))) {
while (false !== ($data = fgetcsv($handle))) {
if (0 === $line) {
$header = $data;
} else {
$data = array_combine($header, $data);
//print_s($data);
}
$line++;
//if (20 < $line){ break;}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment