English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The array_walk_recursive() function applies the user function recursively to each member of the array
array_walk_recursive( $array, $funcname,$parameter])
The array_walk_recursive() function runs the user-defined function for each array element. The keys and values are parameters in the function.
Apply the user-defined function funcname to each element of the array. This function will recurse into deeper arrays.
Returns TRUE on success, or FALSE on failure.
Serial Number | Parameters and Description |
---|---|
1 | array(Required) It specifies an array. |
2 | funcname(Required) The name of the user-defined function. |
3 | paramter(Optional) It specifies a parameter for the user-defined function. |
Apply the user-defined function call_back_function to each element of the array
<?php function call_back_function($value,$key) { echo "Key $key has the value $value \n"; } $input1 = array("a"=>"green", "b"=>"brown", "c"=>"blue" ); $input2 = array($input1, "d"=>"yellow", "e"=>"black"); array_walk_recursive($input2,"call_back_function"); ?>Test and see‹/›
Output result:
The value of key 'a' is 'green' The value of key 'b' is 'brown' The value of key 'c' is 'blue' The value of key 'd' is 'yellow' The value of key 'e' is 'black'