Created
April 20, 2018 14:51
-
-
Save marco-kretz/1ab44bf1f7677e53ab25f96d70c04803 to your computer and use it in GitHub Desktop.
This file contains 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 readCSVWithHeaders($csvString, $delimiter = ';') | |
{ | |
$rows = explode("\n", str_replace("\r", '', $csvString)); | |
$headers = str_getcsv(array_shift($rows), $delimiter); | |
return array_map(function ($row) use ($headers, $delimiter) { | |
return array_combine($headers, str_getcsv($row, $delimiter)); | |
}, array_filter($rows, function($row) { | |
return !empty($row); | |
})); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment