Home > PHP > Function > Arrays > array_reduce()

array_reduce()

array_reduce - Iteratively reduce the array to a single value using a callback function

Syntax

mixed array_reduce (array $input, callback $function, mixed $initial)

Arguments

  • input - The input array.
  • function - The callback function.
  • initial - If the optional initial is available, it will be used at the beginning of the process, or as a final result in case the array is empty.

Description

array_reduce() applies iteratively the function function to the elements of the array input, so as to reduce the array to a single value.

Version

PHP 4.0.5, 5

Return value

Returns the resulting value.