PHP code example of phlak / collection

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

    

phlak / collection example snippets


use PHLAK\Collection;

$collection = new Collection\Collection(['foo', 'bar', 'baz']);

// or

$collection = Collection\Collection::make(['foo', 'bar', 'baz']);

$collection->each(Closure $function);

$collection->map(Closure $function);

$collection->filter(Closure $function);

$collection->reject(Closure $function);

$collection->reduce(Closure $function, $initial);

$collection->sum(Closure $function, $initial);