PHP code example of paalg / csv
1. Go to this page and download the library: Download paalg/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/ */
paalg / csv example snippets
// Load standard CSV file with headers and "," as field separator
$csv = new Csv('import.csv');
$data = $csv->getData();
print_r($data);
print_r($csv->getHeaders());
$csv = new Csv('data.csv');
foreach ($csv as $row) {
print_r($row);
foreach ($row as $fieldName => $value) {
// do things with the fields in current row
}
}