Home >> PHP >> array_walk_recursive() function in PHP

array_walk_recursive() function in PHP

The array_walk_recursive() function used for read one by one keys and values of an array element in a user defined function.

Syntax

array_walk_recursive(array,yourfunction,userdata)

Example

function yourfunction($value,$key){
     echo "The key $key has the value $value<br>";
}
$array1=array("a"=>"ram","b"=>"shyam","c"=>"ravi");

$array2=array($array1,"d"=>"ghanshyam");
array_walk_recursive($array2,"yourfunction");

Output

The key a has the value ram
The key b has the value shyam
The key c has the value ravi
The key d has the value ghanshyam

Post Your Comment

Next Questions
asort() function
arsort() function
compact() function
count() function
current() function
each() function
end() function
extract() function
in_array() function
key() function
krsort() function
ksort() function
list() function
natcasesort() function
natsort() function
pos() function
prev() function
range() function
reset() function
rsort() function
shuffle() function
sizeof() function
sort() function
uasort() function
uksort() function

Copyright ©2022 coderraj.com. All Rights Reserved.