Extend PHP's native CSV parsing from the SplFileObject class but provide features to use the first row's values as keys on the remaining rows.
There are other libraries which accomplish the similar thing, but they are memory inefficient and rely on their own (sometimes buggy) parsing implementation.
<?php
$oCsv = new ParseCsv('users.csv');
$oCsv->firstRowHeader();
foreach($oCsv as $aRow) {
print_r($aRow);
}
Given the example users.csv file:
id,firstName
11,Billy
The resulting output will be:
Array
(
[id] => 11
[firstName] => Billy
)
$ composer require bluefrg/parsecsv:dev-master