PHP code example of izzle / csv

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

    

izzle / csv example snippets


use Izzle\Csv\Reader;
use Izzle\Csv\Config;
use Izzle\Csv\Interpreter;

$interpreter = (new Interpreter())->addObserver(function (array $line) {
    var_dump($line);
});

$csv = new Reader((new Config())->setDelimiter(';')->setIgnoreHeaderLine(true));
$csv->parse(__DIR__ . '/data.csv', $interpreter);

use Izzle\Csv\Config;

$config = new Config();
$config
    ->setDelimiter("\t") // Customize delimiter. Default value is comma(,)
    ->setEnclosure("'")  // Customize enclosure. Default value is double quotation(")
    ->setEscape("\\")    // Customize escape character. Default value is backslash(\)
    ->setToCharset('UTF-8') // Customize target encoding. Default value is null, no converting.
    ->setFromCharset('SJIS-win') // Customize CSV file encoding. Default value is null.
;
bash
php composer.phar install