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