1. Go to this page and download the library: Download dcblogdev/exportcsv 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/ */
dcblogdev / exportcsv example snippets
use Dcblogdev\ExportCsv\ExportCsv;
//set filename
$filename = 'test.csv';
//set column names
$headerFields = ['First Name', 'Last Name', 'Company', 'Created'];
//create array
$records = [];
//loop through data and add to array
foreach($contacts as $row) {
$records[] = [
$row->firstName,
$row->lastName,
$row->companyName,
$row->created_at
];
}
//OR set an array manually
$records[] = ['name', 'last name', 'comy', 'created'];
//send params to csv
new ExportCsv($records, $filename, $headerFields);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.