PHP code example of fusonic / csv-reader

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

    

fusonic / csv-reader example snippets


class Foo
{
    #[TitleMapping('Price')]
    public float $price;

    #[TitleMapping('Price')]
    public function setPrice(float $value): void
    {
        // Not implemented
    }
}

$reader = new CsvReader('myfile.csv');
foreach ($reader->readObjects(Foo::class) as $item) {
    var_dump($item);
}

$options = new CsvReaderOptions();
$options->valueConverter = new IntlValueConverter('de-AT');

$reader = new CsvReader($options);