PHP code example of vakata / collection

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

    

vakata / collection example snippets

 php
$collection = \vakata\collection\Collection::from([1,2,3,4,5,6]);
$result = $collection
    ->filter(function ($v) { return $v % 2 === 0; })
    ->map(function ($v) { return $v + 1; })
    ->head(2)
    ->toArray();