PHP code example of emonkak / collection
1. Go to this page and download the library: Download emonkak/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/ */
emonkak / collection example snippets
// Take five elements from a infinite list of even numbers.
Collection::iterate(0, function($n) { return $n + 1; })
->filter(function($n) { return $n % 2 === 0; })
->take(5)
->each(function($n) { echo $n, PHP_EOL; });
// => 0
// 2
// 4
// 6
// 8