Skip to content

Instantly share code, notes, and snippets.

@Werninator
Created September 12, 2018 09:34
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 Werninator/fd66e9b9e17069da4ab385e07c74d9fa to your computer and use it in GitHub Desktop.
Save Werninator/fd66e9b9e17069da4ab385e07c74d9fa to your computer and use it in GitHub Desktop.
csv with semicolons to assoc array
<?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