Easy Tutorial
❮ Func Filter Input Filter Sanitize Number Int ❯

PHP array_reduce() Function

Complete PHP Array Reference Manual

Example

Sends the values of the array to a user-defined function and returns a string:


Definition and Usage

The array_reduce() function sends the values of the array to a user-defined function and returns a string.

Note: If the array is empty or the initial value is not passed, the function returns NULL.


Syntax

Parameter Description
array Required. Specifies the array.
myfunction Required. Specifies the name of the function.
initial Optional. Specifies the first value to send to the function for processing.

Technical Details

Return Value: Returns the result value.
PHP Version: 4.0.5+
--- ---
Changelog: Since PHP 5.3.0, the initial parameter accepts multiple types (mixed), whereas in versions prior to PHP 5.3.0, it only supported integers.
--- ---

More Examples

Example 1

With the initial parameter:

Example 2

Returns the sum:


❮ Func Filter Input Filter Sanitize Number Int ❯