PHP code example of czproject / csv-iterator

1. Go to this page and download the library: Download czproject/csv-iterator 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/ */

    

czproject / csv-iterator example snippets


$iterator = new CzProject\CsvIterator\CsvIterator('/path/to/file.csv');

// optional:
$iterator->setDelimiter(',');
$iterator->setEnclosure('"');
$iterator->setEscape('\\');
$iterator->setEncoding('UTF-8');

while (($row = $iterator->fetch()) !== NULL) {
	echo $row['id']; // prints '1'
	echo $row['name']; // prints 'Gandalf The White'
}