Home >> PHP >> array_walk() function in PHP

array_walk() function in PHP

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

Syntax

array_walk(array,yourfunction,userdata)

Example

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

Output

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

Post Your Comment

Next Questions
array_walk_recursive() function
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

Copyright ©2022 coderraj.com. All Rights Reserved.