Download the PHP package midnite81/loopy without Composer
On this page you can find all versions of the php package midnite81/loopy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package loopy
Loopy!
This is a PHP package which adds some namespaced array functions. Some of these functions can be natively accessed using array_* however there are few which aren't natively available.
Installation
This package is available for PHP7.4+. To install use composer
Available Functions
- each
- all
- some
- map
- reduce
- filter
- times
- once
Definitions
each
each(iterable $items, Closure $callback): void
This function loops over each item. If the result of the closure returns false, then it will break the iteration at the point it returns false.
Example
Result
all
all(iterable $items, Closure $callback): bool
This function checks to see if the result of the closure ($callback) is true for all iterations of the iterable passed ($items)
Example
Result
some
some(iterable $items, Closure $callback): bool
This function checks to see if the result of the closure ($callback) is true for one or more iterations of the iterable passed ($items)
Example
Result
map
map(iterable $items, Closure $callback): array
Example
Result
reduce
This function reduces down the values of an array to a single string, integer or float.
Example
Result
filter
filter(iterable $items, Closure $callback, bool $preserveKey = false): array
This function filters down the iterable ($items) passed by only including what is true in the Closure ($callback). By default, the key is not preserved, but you can set it to true, if you wish to preserve the key.
Example
Result
times
times(iterable $items, Closure $callback, int $times): bool
This function checks to see that the instance of the call back ($callback) should only be found the specified number of times in the iterable ($items)
Example
Result
once
once(iterable $items, Closure $callback): bool
Once is exactly the same as times
however it will ensure the result of the closure only
appears once in the iterable passed;
Example
Result