diff --git a/reference/array/functions/array-walk-recursive.xml b/reference/array/functions/array-walk-recursive.xml index bf87ac04e3..5eff6c7a13 100755 --- a/reference/array/functions/array-walk-recursive.xml +++ b/reference/array/functions/array-walk-recursive.xml @@ -1,86 +1,81 @@ - - - - array_walk_recursive - - Apply a user function recursively to every member of an array - - - - Description - - boolarray_walk_recursive - arrayinput - stringfuncname - mixeduserdata - - - &return.success; - - - Applies the user-defined function function to each - element of the array array. This function will recur - into deeper arrays. Typically, function takes on two - parameters. The array parameter's value being the first, and - the key/index second. If the optional userdata - parameter is supplied, it will be passed as the third parameter to - the callback function. - - - - If function needs to be working with the - actual values of the array, specify the first parameter of - function as a - reference. Then, - any changes made to those elements will be made in the - original array itself. - - - - - <function>array_walk_recursive</function> example - + + + + array_walk_recursive + + Apply a user function recursively to every member of an array + + + + Description + + boolarray_walk_recursive + arrayinput + stringfuncname + mixeduserdata + + + Applies the user-defined function funcname to each + element of the input array. This function will recur + into deeper arrays. Typically, funcname takes on two + parameters. The input parameter's value being the first, and + the key/index second. If the optional userdata + parameter is supplied, it will be passed as the third parameter to + the callback funcname. + + + &return.success; + + + + If funcname needs to be working with the + actual values of the array, specify the first parameter of + funcname as a + reference. Then, + any changes made to those elements will be made in the + original array itself. + + + + + <function>array_walk_recursive</function> example + 'apple', 'b' => 'banana'); $fruits = array('sweet' => $sweet, 'sour' => 'lemon'); -function test_alter(&$item1, $key, $prefix) +function test_print($item, $key) { - $item1 = "$prefix: $item1"; + echo "$key holds $item\n"; } -function test_print($item2, $key) -{ - echo "$key. $item2
\n"; -} - -echo "Before ...:\n"; -array_walk($fruits, 'test_print'); - -array_walk($fruits, 'test_alter', 'fruit'); -echo "... and after:\n"; - -array_walk($fruits, 'test_print'); +array_walk_recursive($fruits, 'test_print'); ?> ]]> -
- - The printout of the program above will be: - - - - -
+
+ + The printout of the program above will be: - - See also array_walk - -
-
+ + + + + You may notice that the key 'sweet' is never displayed. Any key that holds an + array will not be passed to the function. + + + + + See also array_walk. + + + +--> \ No newline at end of file