PHP code example of bolstad / csv-parser
1. Go to this page and download the library: Download bolstad/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/ */
bolstad / csv-parser example snippets
use CsvParser\Simple;
function handler ( $data ) {
print_r( $data );
}
/*
Parameters for parseRowByRow:
* @param string $filename File to parse
* @param string $callback Callback function to send data to
* @param int $line Length - Must be greater than the longest line (in characters) to be found in the CSV file (allowing for trailing line-end characters).
* @param str $delimiter Set the field delimiter (one character only).
* @param str $enclosure Set the field enclosure character (one character only)
* @param type $escape Set the escape character (one character only). Defaults as a backslash.
* @param bool $autoDetectHeader Try to auto detect header rows - if false, line 1 i always used
* @return bool
*/
Simple::parseRowByRow('file.csv' ,'handler');