PHP code example of tomaskarlik / csvutils
1. Go to this page and download the library: Download tomaskarlik/csvutils 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/ */
tomaskarlik / csvutils example snippets
$arrayToCsv = new ArrayToCsvString;
$arrayToCsv->setIncludeBom(TRUE);
$arrayToCsv->setHeader([
'Header 1',
'Header 2',
'Header 3'
]);
$arrayToCsv->addColumnCallback('price', [$this, 'formatFloat']);
$arrayToCsv->addColumnCallback('sales', [$this, 'formatFloat']);
$arrayToCsv->addColumnCallback('cost_of_sales', [$this, 'formatFloat']);
$yourCsvInString = $arrayToCsv->convert($rows);