PHP code example of foued611 / parsecsv

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

    

foued611 / parsecsv example snippets


use Parse\Csv\ParseCSV;



$csv = new ParseCSV('data.csv');
print_r($csv->data);

$csv = new \Parse\Csv\ParseCSV();
$csv->encoding('UTF-16', 'UTF-8');
$csv->delimiter = "\t";
$csv->parse('data.tsv');
print_r($csv->data);

$csv = new ParseCSV();
$csv->auto('data.csv');
print_r($csv->data);

$csv = new \Parse\Csv\ParseCSV();
$csv->sort_by = 'id';
$csv->parse('data.csv');
# "4" is the value of the "id" column of the CSV row
$csv->data[4] = array('firstname' => 'John', 'lastname' => 'Doe', 'email' => '[email protected]');
$csv->save();

$csv = new ParseCSV();
$csv->save('data.csv', array('1986', 'Home', 'Nowhere', ''), true);

$csv = new ParseCSV();
$csv->output('movies.csv', $array, array('field 1', 'field 2'), ',');