PHP csv builder
, (*1)
Build csv file and save or download it. Simple librery to write csv file in your php application, (*2)
Install
Install php-csv-builder
with Composer., (*3)
$ composer require silverkron/php-csv-builder
Initialize the class
use CsvBuilder\CsvBuilder;
$csvBuilder = new CsvBuilder();
Available methods
Change default destination path
setFilePath(<string>)
, (*4)
$csvBuilder->setFilePath('/path/to/file');
Change default file name
setFileName(<string>)
, (*5)
$csvBuilder->setFileName('/path/to/file');
Set row of titles (required)
setTitles(<array>)
, (*6)
$csvBuilder->setTitles([
'Title 1',
'Title 2',
'Title 3',
'Title 4'
]);
Clear all rows
clearRows(<array>)
, (*7)
$csvBuilder->clearRows();
Add new row (required)
addRow(<array>)
, (*8)
$csvBuilder->addRow([
'Column 1',
'Column 2',
'Column 3',
'Column 4',
]);
Build the csv file (required for download)
create()
, (*9)
$csvBuilder->create();
Download csv file
download()
, (*10)
$csvBuilder->download();
License
The MIT License (MIT). Please see LICENSE for more information., (*11)