trait ReducePart

Methods

mixed
reduce(callable $callback, mixed $fallback = null)

Iterative reduction of this array or collection with the help of a callback function. The callback function takes two parameters, the first is the carry, the second the current item, with this signature: mixed callback(mixed $carry, mixed $item)

Details

at line 25
mixed reduce(callable $callback, mixed $fallback = null)

Iterative reduction of this array or collection with the help of a callback function. The callback function takes two parameters, the first is the carry, the second the current item, with this signature: mixed callback(mixed $carry, mixed $item)

Parameters

callable $callback the callback function
mixed $fallback the default value, that will be returned when the list is empty

Return Value

mixed