PHP code example of splitpay / support-csv

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

    

splitpay / support-csv example snippets




plitpay\Support\Csv\Parser;
use Splitpay\Support\Csv\Layout;
use Splitpay\Support\Csv\Column;

// Creating columns
$userName = new Column(name: 'userName', type: 'string', alias: 'user', filters: ['trim', 'strtolower', 'ucwords']);
$email = new Column(name: 'email', type: 'string');
$password = new Column('password');

// Creating the layout
$layout = new Layout([$userName, $email, $password]);

// Creating the parser
$parser = new Parser($layout);

// Converting array to CSV
$csv = $parser->parseFromArray([
  [
    'userName' => 'Esdras Schonevald',
    'email' => '[email protected]',
    'password' => '!ChangeMe@123!'
  ],
  [
    'userName' => 'Joao Ricardo',
    'email' => '[email protected]',
    'password' => '!ChangeMe@123!'
  ],
  [
    'userName' => 'Yago Tomaz',
    'email' => '[email protected]',
    'password' => '!ChangeMe@123!'
  ]
]);

echo $csv;