| Previous | Home | Next |
array_reduce()
The array_reduce() function sends the values in an array to a user-defined function, and returns a string.
Syntax:array_reduce(array,myfunction,initial)
In above syntax, "array" specifies an array, "myfunction" specifies the name of the function and "initial" specifies the initial value to send to the function
Example:
<?php
function myfunction($var1,$var2)
{
return $var1 . "or" . $var2;
}
$arr=array(" Apple "," Orange "," Mango ");
print_r(array_reduce($arr, "myfunction",1));
?>
Output:
| Previous | Home | Next |