1. Go to this page and download the library: Download luispastendev/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/ */
luispastendev / csv-generator example snippets
use CSVGenerator\CSVGenerator;
// Especificamos la ruta de donde se generara el archivo con ext csv.
// si el archivo ya existe se creara uno nuevo
$file = __DIR__ . '/test.csv';
// clasico
$csv_generator = new CSVGenerator;
$csv_generator->create($file, ['id', 'name', 'company']);
$csv_generator->add([1, 'luis', 'company1']);
$csv_generator->add([2, 'foo', 'company2']);
// chaining functions
(new CSVGenerator)->create($file, ['id', 'name', 'company'])
->add([
[1, 'luis', 'company1'],
[2, 'foo', 'company2']
]);
/**
* Se encarga de agregar data a un archivo existente regresa
* falso si ocurrio algun problema
*
* @param array $rows
*
* @return bool
*/
// rows puede ser un array unidimensional o bidi ej: [..] o [[...], [...]]
$obj->add(array $rows);
/**
* Se encarga de crear un archivo y agregar datos
*
* @param string $path
* @param array $rows
* @return self
*/
// rows puede ser un array unidimensional o bidi ej: [..] o [[...], [...]]
$obj->create(string $pathfile, array $rows);
/**
* Establece un archivo para trabajar sobre el.
*
* @param string $path
* @return self
*/
$obj->setFile(string $path);
/**
* Regresa información del archivo nuevo o existente.
*
* @return array
*/
$obj->getFileInfo(string $path);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.