dev-master
9999999-devLightweight php package to work with arrays like in JavaScript or C#. Immutable-first. Collections-like
MIT
The Requires
- php >=7.0.0
The Development Requires
javascript array prototype chainable collections-like
Lightweight php package to work with arrays like in JavaScript or C#. Immutable-first. Collections-like
Lightweight php package to work with arrays like (but fitted to PHP) in JavaScript or C#, so you can for example, chain methods. Immutable-first. Collections-like., (*1)
Project was built having in mind, that this library has to:, (*2)
Install the latest version with, (*3)
$ composer require dragk/array-class
<?php use DragK\ArrayClass; $array = new ArrayClass([1, 3, 2, 4]); $result = $array ->sort() ->reverse() ->map(function($value){ return $value**2; }) ->filter(function($value) { return $value > 8 ; }) ->reduce(function($result, $value) { return $result + $value; }); var_dump($result); // int(25) echo $array[1]; // 3
Remember, you can always use function () use ($var1, $varN)
to pass to function more variables, for example.:, (*4)
$multiplier = 2; $result = $array ->sort() ->reverse() ->map(function($value){ return $value**2; }) ->filter(function($value) { return $value > 8 ; }) ->reduce(function($result, $value) use ($multiplier) { return ($result + $value) * $multiplier; }); echo $result; // 82
Bugs, feature request and code style/approach hints are tracked on GitHub, (*5)
ArrayClass is licensed under the MIT License - see the LICENSE file for details, (*6)
This library is inspired by JavaScript Array Object, although most concepts have been adjusted to fit to the PHP world., (*7)
Lightweight php package to work with arrays like in JavaScript or C#. Immutable-first. Collections-like
MIT
javascript array prototype chainable collections-like