Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 727 Bytes

README.md

File metadata and controls

37 lines (29 loc) · 727 Bytes

ParseCsv

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
)

Install

$ composer require bluefrg/parsecsv:dev-master