Created
September 12, 2018 09:34
-
-
Save Werninator/fd66e9b9e17069da4ab385e07c74d9fa to your computer and use it in GitHub Desktop.
csv with semicolons to assoc 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 | |
// modified version of https://steindom.com/articles/shortest-php-code-convert-csv-associative-array | |
function str_getcsv_semicolons($input) { | |
return str_getcsv($input, ';'); | |
} | |
$rows = array_map('str_getcsv_semicolons', file($filedir)); | |
$header = array_shift($rows); | |
$data = []; | |
foreach ($rows as $row) | |
$data[] = array_combine($header, $row); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment