Send the values in an array to a user-defined function and return a string:
The array_reduce() function sends the values in an array to a user-defined function, and returns a string.
Note: If the array is empty and initial is not passed, this function returns NULL.
Parameter | Description |
---|---|
array | Required. Specifies an array |
myfunction | Required. Specifies the name of the function |
initial | Optional. Specifies the initial value to send to the function |
Return Value: | Returns the resulting value |
---|---|
PHP Version: | 4.0.5+ |
Changelog: | As of PHP 5.3.0, the initial parameter accepts multiple types (mixed). Versions prior to PHP 5.3.0, only allowed integer. |
With the initial parameter:
Returning a sum: