1. Go to this page and download the library: Download albinvar/php-csv-generator 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/ */
albinvar / php-csv-generator example snippets
composer
use PhpCsv\Generator;
composer update albinvar/php-csv-generator
use PhpCsv\Generator;
$array = [
['John', 28],
['Johana', 23],
['Adam', 32],
];
$object = new Generator();
$object->setArray($array, $columns);
$object->makeCsv();
$object->getCsv(); //(Optional) Get CSV as a string.
$object->exportCsv('data.csv', true);
use PhpCsv\Generator;
object->importCsv('data.csv');
$array = $object->getArray();
var_dump($array);
use PhpCsv\Generator;
object->importJson('data.json');
$array = $object->getArray();
var_dump($array);
// returns json string.
echo $object->exportJson();
// creates json file and download to browser.
$object->exportJson('data.json', true);
// creates json file and saves it to specific location.
$object->exportJson('data.json', false);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.