1. Go to this page and download the library: Download taranto/csv-parser 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/ */
taranto / csv-parser example snippets
$csvParser = new CsvParser('file.csv');
$csvAsArray = $csvParser->getCsvAsArray();
$csvParser = new CsvParser('file.csv');
$csvAsArray = $csvParser->getCsvAsAssociativeArray();
$csvParser = new CsvParser('file.csv');
$csvAsArray = [];
foreach ($csvParser as $row) {
$csvAsArray[] = $row;
}
$csvParser = new CsvParser('file.csv', true);
$csvAsArray = [];
foreach ($csvParser as $row) {
$csvAsArray[] = $row;
}
$csvParser = new CsvParser('file.csv');
$csvAsArray = $csvParser->getCsvAsAssociativeArray(1, 2);