PHP code example of mdantas / csv-map

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

    

mdantas / csv-map example snippets


use CsvMap\Collection;

$fileCsvPath = './filecsv';

$csvCollection = Collection::factory($fileCsvPath);

$csvCollection->getHeaders(): array;

$csvCollection->hasHeader('headerName'): bool;
 
$csvCollection->combine('id', 'name', 'id', ...): array;
    
$csvCollection->groupBy('id'): array;

$csvCollection->extract('id', true): array // Last param remove duplicated registers

$csvCollection->isEmpty(): bool;

$csvCollection->each(function($item) => {
    print_r($item);
});

$csvCollection->toArray();