PHP code example of stdakov / csv

1. Go to this page and download the library: Download stdakov/csv 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/ */

    

stdakov / csv example snippets




$file = 'export.csv'; //It is optional

$path = 'somePath'; //It is optional

$csv = new \Dakov\CSV();

$csv = new \Dakov\CSV($path);
$csv->setFile($file);

$data = [
    [
        'column1' => 1,
        'column2' => 1,
    ],
    [
        'column1' => 2,
        'column2' => 2,
    ],
];

$csv->create($data);

$data = [
    [
        'column1' => 3,
        'column2' => 3,
    ],
    [
        'column1' => 4,
        'column2' => 4,
    ],
    [
        'column1' => 5,
        'column2' => 5,
    ],
];

$csv->append($data);

print_r($csv->read());

print_r($csv->readReverse());

print_r($csv->readReverse(2));

$csv->download();

$csv->download(true);

php composer.phar