PHP code example of jwage / easy-csv

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

    

jwage / easy-csv example snippets


$reader = new \EasyCSV\Reader('read.csv');

while ($row = $reader->getRow()) {
    print_r($row);
}

print_r($reader->getAll());

// our headers aren't on the first line
$reader = new \EasyCSV\Reader('read.csv', 'r+', false);
// zero-based index, so this is line 4
$reader->setHeaderLine(3);

$writer = new \EasyCSV\Writer('write.csv');

$writer->writeRow('column1, column2, column3');

$writer->writeRow(array('column1', 'column2', 'column3'));

$writer->writeFromArray(array(
    'value1, value2, value3',
    array('value1', 'value2', 'value3')
));