|
|
PHP array_walk_recursive() Function
|
Tutorials » Php »
|
Topic |
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.
|
|
A Note |
Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial.
Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.
|
|
|
|