PHP code example of value3 / csv-reader
1. Go to this page and download the library: Download value3/csv-reader library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
value3 / csv-reader example snippets
use Value3\CsvReader\CsvReader;
$reader = new CsvReader();
foreach ($reader->read('path/some-file.csv') as $row) {
echo $row['name'] . PHP_EOL;
echo $row['last_name'] . PHP_EOL;
}
//working with streams
$fp = fopen('path/some-file.csv', 'r+');
foreach ($reader->read($fp) as $row) {
echo $row['name'] . PHP_EOL;
echo $row['last_name'] . PHP_EOL;
}