1. Go to this page and download the library: Download jamesgordo/php-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/ */
jamesgordo / php-csv-parser example snippets
// load vendor autoload
// Initalize the Parser
$users = new Parser('/path/to/users.csv');
// loop through each user and echo the details
foreach($users->all() as $user) {
echo "User Details: {$user->id} | {$user->first_name} {$user->last_name}";
}
echo "Total Parsed: " . $users->count() . " Users";
// load vendor autoload
// Initalize the Parser with custom delimiter
$users = new Parser('/path/to/users.csv', "|");
$users = new Parser('/path/to/users.csv') // Initializes the Parser
$users->setCsv('/path/to/file.csv'); // Sets the File to be Parsed
$users->getCsv(); // Returns the File to be Parsed
$users->checkFile('/path/to/file.csv'); // Validates if File is a valid CSV File
$users->parse(); // Triggers the Parsing of CSV file
$users->all(); // Returns array of Data Objects parsed from the CSV file
$users->count(); // Returns the total rows parsed from the CSV file
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.