Created
August 31, 2020 16:27
-
-
Save aguinaldotupy/5d36e4ff98710e6ff26e61881a5db445 to your computer and use it in GitHub Desktop.
Read csv file
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
public function csvToArray($file) | |
{ | |
$data = []; | |
$rows = array_map('str_getcsv', file($file)); | |
$header = array_shift($rows); | |
foreach ($rows as $row) { | |
$data[] = array_combine($header, $row); | |
} | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment