The array_walk() method applies a user-defined function to each member of an array. Returns TRUE on success and FALSE on failure.
array_walk(arr, custom_func, parameter)
arr - The specified array. Required.
custom_func - User-defined function. Required.
#parameter - Parameters set for the custom function. Optional.
The array_walk() function returns TRUE on success and FALSE on failure.
The following is an example-
Live Demo
<?php function display($val,$key) { echo "$key id : Student $val<br>"; } $arr = array("p"=>"Tom","q"=>"Jack","r"=>"Amit"); array_walk($arr,"display"); ?>
The following is the output-
p id : Student Tom q id : Student Jack r id : Student Amit
The above is the detailed content of array_walk() function in PHP. For more information, please follow other related articles on the PHP Chinese website!