Skip to content

Instantly share code, notes, and snippets.

@nicopenaredondo
Created April 24, 2018 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicopenaredondo/14e65cfa54594b7e6223711b7a8b23ad to your computer and use it in GitHub Desktop.
Save nicopenaredondo/14e65cfa54594b7e6223711b7a8b23ad to your computer and use it in GitHub Desktop.
private function csvToArray($filename='', $delimiter=',')
{
$rows = array_map('str_getcsv', file($filename));
$header = array_shift($rows);
$csv = array();
foreach ($rows as $row) {
if(count($row) != count($header)) {
dd($row);
}
$csv[] = array_combine($header, $row);
}
return $csv;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment