PHP code example of webgriffe / amp-csv

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

    

webgriffe / amp-csv example snippets




use Webgriffe\AmpCsv\Iterator;
use Webgriffe\AmpCsv\Parser;
use Amp\File;

open('path/to/file.csv', 'rb')));
    while (yield $iterator->advance()) {
        $rows[] = $iterator->getCurrent();
    }
    var_dump($rows);
});

$iterator = new Iterator(new Parser(yield File\open('path/to/file.csv', 'rb')), false);
text
array(
    array(
        'Name' => 'RaspberryPi',
        'Description' => 'Raspberry PI Modell B, 512 MB',
        'Price' => 37.05,
        'Stock' => 12,
    ),
    array(
        'Name' => 'SanDisk Ultra SDHC',
        'Description' => 'SanDisk Ultra SDHC 8 GB 30 MB/s Classe 10',
        'Price' => 6.92,
        'Stock' => 54,
    ),
),