PHP code example of pfuri / awesome-php-csv

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

    

pfuri / awesome-php-csv example snippets


use pfuri\AwesomePHPCSV;

$apcsv = new AwesomePHPCSV();



$options = array(
    'pathToFile' => 'example.csv',
    'hasHeaderRow' => true
);

$data = $apcsv->import($options);
if($data === false) {
    // false means there was some kind of error
    // error messages can be found in the error message array
    $errorMessages = $apcsv->errorMessages;
    print_r($errorMessages);
}

[
    [2016, Cadillac, Escalade, Black],
    [2016, Mercedes Benz, ML350, Black]
]
javascript
{
    ...
    "ri/awesome-php-csv": "~2.1",
        ...
    }
    ...
}