1--TEST--
2Test array_walk_recursive() function : usage variations - 'input' array with subarray
3--FILE--
4<?php
5/* Prototype  : bool array_walk_recursive(array $input, string $funcname [, mixed $userdata])
6 * Description: Apply a user function to every member of an array
7 * Source code: ext/standard/array.c
8*/
9
10/*
11 * Testing array_walk_recursive() with an array having subarrays as elements
12*/
13
14echo "*** Testing array_walk_recursive() : array with subarray ***\n";
15
16// callback function
17/* Prototype : callback(mixed $value, mixed $key)
18 * Parameters : $value - values in given 'input' array
19 *              $key - keys in given 'input' array
20 * Description : It prints the count of an array elements, passed as argument
21 */
22function callback($value, $key)
23{
24   // dump the arguments to check that they are passed
25   // with proper type
26   var_dump($key);  // key
27   var_dump($value); // value
28   echo "\n"; // new line to separate the output between each element
29}
30
31$input = array(
32  array(),
33  array(1),
34  array(1,2,3),
35  array("Mango", "Orange"),
36  array(array(1, 2, 3), array(1))
37);
38
39var_dump( array_walk_recursive( $input, "callback"));
40
41echo "Done"
42?>
43--EXPECT--
44*** Testing array_walk_recursive() : array with subarray ***
45int(0)
46int(1)
47
48int(0)
49int(1)
50
51int(1)
52int(2)
53
54int(2)
55int(3)
56
57int(0)
58string(5) "Mango"
59
60int(1)
61string(6) "Orange"
62
63int(0)
64int(1)
65
66int(1)
67int(2)
68
69int(2)
70int(3)
71
72int(0)
73int(1)
74
75bool(true)
76Done
77