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.
The basic syntax of the array_reduce()
function is given with:
array_reduce(array, myfunction, initial);
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 |
Example1 : Send the values in an array to a user-defined function and return a string:
Output : -Web-Designing-House
Example 2: following example with initial parameter
Output : 5-Dog-Cat-Horse