PHP code example of designbeat / csv-matcher

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

    

designbeat / csv-matcher example snippets


use DesignBeat\Matchers\CSV\CsvMatcher;
use DesignBeat\Matchers\CSV\CsvReader;

$scheme = [
    0 => 'user.name',
    1 => 'user.surname',
    2 => 'city',
    3 => 'extra.id',
    4 => 'extra.x',
];

$matcher = new CsvMatcher(new CsvReader(__DIR__ . '/tests/cases/files/fixtures.csv'));
$result = $matcher->match($scheme);

0 => [
    'user' => [
        'name' => 'Milan',
        'surname' => 'Sulc',
    ],
    'city' => 'HK',
    'extra' => [
        'id' => '123456',
        'x' => 'foo',
    ],
],
1 => [
    'user' => [
        'name' => 'John',
        'surname' => 'Doe',
    ],
    'city' => 'Doens',
    'extra' => [
        'id' => '111111',
        'x' => 'bar',
    ],
],