PHP array_walk_recursive() Function
What is array_walk_recursive() Function?
Explanation
The "array_walk_recursive()" function apply a user function recursively to every member of an array.
Syntax:
array_walk_recursive(array,function,parameter)
In the above syntax all elements of the "array" is called in an user defined "function" recursivley, even there can be some parameters given using "parameters" option.
Example :
<?php
function funct1($value,$key)
{
echo "The key $key has the value $value <br/>";
}
$a=array("a"=>"Guava","b"=>"Orange");
$b=array($a,"1"=>"Cherry","2"=>"Apple");
array_walk_recursive($b,"funct1");
?>
Result :
The key a has the value Guava
The key b has the value Orange
The key 1 has the value Cherry
The key 2 has the value Apple
In the above example all the elements of the array "$a","$b" are send to the user defined function recursively and the result is displayed.