From 890f1d16c2f35e9db4f3369120dabe0dd5516fb1 Mon Sep 17 00:00:00 2001 From: Aidan Lister Date: Tue, 3 Aug 2004 07:07:13 +0000 Subject: [PATCH] Half documented - I was unable to complete it because PHP segfaults when I use the function! Commiting so we don't double up on the work git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@165032 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../array/functions/array-walk-recursive.xml | 65 ++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/reference/array/functions/array-walk-recursive.xml b/reference/array/functions/array-walk-recursive.xml index 2a17d6eb27..bf87ac04e3 100755 --- a/reference/array/functions/array-walk-recursive.xml +++ b/reference/array/functions/array-walk-recursive.xml @@ -1,5 +1,5 @@ - + array_walk_recursive @@ -15,9 +15,70 @@ 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 + + 'apple', 'b' => 'banana'); +$fruits = array('sweet' => $sweet, 'sour' => 'lemon'); - &warn.undocumented.func; +function test_alter(&$item1, $key, $prefix) +{ + $item1 = "$prefix: $item1"; +} +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'); +?> +]]> +
+ + The printout of the program above will be: + + + + +
+
+ + See also array_walk +