Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CollectionInterface.php

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\Collection

Code

public function reduce(callable $callback, mixed $initial) : mixed;

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal