function CollectionInterface::reduce
Apply a given callback method on each item of the collection to reduce it to a single value.
See the {@link http://php.net/manual/en/function.array-reduce.php PHP array_reduce() documentation} for examples of how the `$callback` and `$initial` parameters work.
@template TCarry
Parameters
callable(TCarry, T): TCarry $callback A callable to apply to each: item of the collection to reduce it to a single value.
TCarry $initial This is the initial value provided to the callback.:
Return value
TCarry
1 method overrides CollectionInterface::reduce()
- AbstractCollection::reduce in vendor/
ramsey/ collection/ src/ AbstractCollection.php - @template TCarry
File
-
vendor/
ramsey/ collection/ src/ CollectionInterface.php, line 211
Class
- CollectionInterface
- A collection represents a group of values, known as its elements.
Namespace
Ramsey\CollectionCode
public function reduce(callable $callback, mixed $initial) : mixed;