-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Maxime Mérian edited this page Sep 18, 2013
·
2 revisions
This library is designed to help reading and writing CSV files
Let's assume you are trying to read a file that looks like this :
id;first_name;last_name;email
1;John;Doe;[email protected]
2;Dave;Null;[email protected]
You would use this snippet
<?php
use Csv\Reader;
$reader = new Reader('myfile.csv', array('hasHeader' => true, 'delimiter' => ';'));
foreach ($reader as $line) {
echo $line['first_name'] . ' ' . $line['last_name'] . PHP_EOL
}
/*
* Will print
* John Doe
* Dave Null
*/