PHP code example of pingpong / csv-reader

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

    

pingpong / csv-reader example snippets


'CsvReader' => 'Pingpong\CsvReader\Facades\CsvReader',

$path = app_path('file.csv');

$csv = CsvReader::get($path); 

// OR

$csv = CsvReader::make($path);

$data = $csv->getData();

$data = $csv->toArray();

$data = $csv->toJson();

$data = $csv->toObject();

foreach($csv as $item)
{
	var_dump($item);
}

$path = __DIR__ . '/path/to/csvfile.csv';

$csv = new Pingpong\CsvReader\CsvReader($path);

$data = $csv->getData();