← All docs

array_reduce()

Iteratively reduces an array to a single value using a callback function.

array_reduce()

function array_reduce(array $array, callable $callback, mixed $initial = null): int

Iteratively reduces an array to a single value using a callback function.

Parameters:

  • $array (array)
  • $callback (callable)
  • $initial (mixed), default null, optional

Returns: int

No examples yet — check examples/ and showcases/ for usage patterns.

Internals

For how array_reduce is implemented in the compiler, see the internals page.