PHP code example of softboxlab / php-collection-helper

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

    

softboxlab / php-collection-helper example snippets


$collection = new Collection([1, 2, 3, 4]);
$newCollection = $collection->map(function ($item) {
    return $item * 2;
});

print_r($newCollection->all()); // [2, 4, 6, 8]
print_r($collection->all()); // [1, 2, 3, 4]

$transformer = new Transformer(['namae' => 'nombre']);
$data = ['namae' => 'William'];
$transformedData = $transformer->transform($data);

print_r($transformedData); // ['nombre' => 'William'];