PHP code example of satthi / csv-combine
1. Go to this page and download the library: Download satthi/csv-combine 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/ */
satthi / csv-combine example snippets
use CsvCombine\Export\CsvExport;
$csvExport = new CsvExport();
$list = array(
array('a','b','cc'),
array('あa','b','cc'),
);
$file = 'export.csv';
$options = array(
'export_encoding' => 'UTf-8',
);
$csvExport->make($list, $file);
use CsvCombine\Import\CsvImport;
use CsvCombine\Import\FixedLengthImport;
$CsvImport = new CsvImport();
$filename = 'export.csv';
$list = array('A','B','C');
print_r($CsvImport->import($filename, $list));
use CsvCombine\Export\FixedLengthExport;
$FixedLengthExport = new FixedLengthExport();
$list = array(
array('a','b','cc'),
array('あa','b','cc'),
);
$file = 'export.txt';
$options = array(
'export_encoding' => 'UTf-8',
);
$fixed_options = array(
array('length' => 20, 'type' => 'text'),
array('length' => 20, 'type' => 'text'),
array('length' => 20, 'type' => 'text'),
);
$FixedLengthExport->make($list, $file, $fixed_options);
use CsvCombine\Import\FixedLengthImport;
$FixedLengthImport = new FixedLengthImport();
$filename = 'export.txt';
$list = array(
array('name' => 'A', 'length' => 20),
array('name' => 'B', 'length' => 20),
array('name' => 'C', 'length' => 20),
);
print_r($FixedLengthImport->import($filename, $list));