emonkak / underbar.php
A collection processing library for PHP, like Underscore.js
Installs: 11 412
Dependents: 2
Suggesters: 1
Security: 0
Stars: 40
Watchers: 7
Forks: 3
Open Issues: 0
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is auto-updated.
Last update: 2022-02-01 12:23:55 UTC
README
Underbar.php is a collection processing library for PHP, like underscore.js.
However not aim full compatibility of undersocre.js.
Requirements
- PHP 5.4 or higher
- Composer
Licence
MIT Licence
Getting Started
- Install Composer.
- Create the
composer.json
- Execute
composer.phar install
composer.json
{ "require": { "emonkak/underbar.php": "dev-master" } }
Example
// There are also ArrayImpl and GeneratorImpl. use Underbar\IteratorImpl as _; // Take five elements from a infinite list of even numbers. _::chain(0) ->iterate(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 // Get a first element. echo _::first(array(100)), PHP_EOL; // => 100