1. Go to this page and download the library: Download rskuipers/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/ */
rskuipers / csv example snippets
use RSKuipers\CSV\File;
$file = new File($this->getCSVFile(), 0);
$file->setMappingMode(File::COLUMN_TITLES);
$row = $file->fetch();
echo $row['Name'];
use RSKuipers\CSV\File;
$file = new File($this->getCSVFile(), 0);
$file->setMappingMode(File::INDEX);
$row = $file->fetch();
echo $row[1];
use RSKuipers\CSV\File;
$file = new File($this->getCSVFile(), 0);
$file->setMappingMode(File::CUSTOM);
$file->setMapping(array(
'ID',
'Product Name',
'Price',
));
$row = $file->fetch();
echo $row['Product Name'];
use RSKuipers\CSV\File;
use RSKuipers\CSV\Formatter\Currency as CurrencyFormatter;
use RSKuipers\CSV\Formatter\Decimal as DecimalFormatter;
$priceFormatter = new CurrencyFormatter('nl_NL');
$decimalFormatter = new DecimalFormatter('nl_NL');
$csv = new File($this->getCSVFile(), 0);
$csv->setMappingMode(File::COLUMN_TITLES);
$csv->setFormatter('Price', $priceFormatter);
$csv->setFormatter('Stock', $decimalFormatter);
$row = $csv->fetch();
echo $row['Price']; // 15.95
echo $row['Stock']; // 2093230