1--TEST--
2Test array_walk_recursive() function : basic functionality - regular array
3--FILE--
4<?php
5echo "*** Testing array_walk_recursive() : basic functionality ***\n";
6
7// regular array
8$fruits = array("lemon", array("orange", "banana"), array("apple"));
9
10function test_print($item, $key)
11{
12   // dump the arguments to check that they are passed
13   // with proper type
14   var_dump($item); // value
15   var_dump($key);  // key
16   echo "\n"; // new line to separate the output between each element
17}
18function with_userdata($item, $key, $user_data)
19{
20   // dump the arguments to check that they are passed
21   // with proper type
22   var_dump($item); // value
23   var_dump($key);  // key
24   var_dump($user_data); // user supplied data
25   echo "\n"; // new line to separate the output between each element
26}
27
28echo "-- Using array_walk_recursive() with default parameters to show array contents --\n";
29var_dump( array_walk_recursive($fruits, 'test_print'));
30
31echo "-- Using array_walk_recursive() with all parameters --\n";
32var_dump( array_walk_recursive($fruits, 'with_userdata', "Added"));
33
34echo "Done";
35?>
36--EXPECT--
37*** Testing array_walk_recursive() : basic functionality ***
38-- Using array_walk_recursive() with default parameters to show array contents --
39string(5) "lemon"
40int(0)
41
42string(6) "orange"
43int(0)
44
45string(6) "banana"
46int(1)
47
48string(5) "apple"
49int(0)
50
51bool(true)
52-- Using array_walk_recursive() with all parameters --
53string(5) "lemon"
54int(0)
55string(5) "Added"
56
57string(6) "orange"
58int(0)
59string(5) "Added"
60
61string(6) "banana"
62int(1)
63string(5) "Added"
64
65string(5) "apple"
66int(0)
67string(5) "Added"
68
69bool(true)
70Done
71