Released PHPCsvParser 1.3.0 - 26 Jul 2013

Changes in 1.3.0

  • Added new options: offset, limit, header

New Option offset and limit

If you prefer skip first line of CSV, you can use offset option from 1.3. limit option is for limit maximum count of records.

<?php

use \KzykHys\CsvParser\CsvParser;

$parser = CsvParser::fromFile('./test.csv', array(
    'offset' => 1,
    'limit'  => 100
));
$result = $parser->parse();

New Option header

You can specify array key of each columns by header option.

test.csv:

kzykhys,"test@example.com","http://example.com","0123-4567-89"

test.php

<?php

$parser = CsvParser::fromFile('./test.csv', array('header', array(
    'name', 'email', 'url', 'phone'
)));
$result = $parser->parse();

// [
//    'name'  => 'kzykhys',
//    'email' => 'test@example.com',
//    'url'   => 'http://example.com',
//    'phone' => '0123-4567-89'
// ]

Get PHPCsvParser

You can install PHPCsvParser 1.3.0 via Composer

{
    "require": {
        "kzykhys/php-csv-parser": "~1.1.0"
    }
}

Or download tarball or zipball

comments powered by Disqus