1--TEST--
2Test each() function : usage variations - Multi-dimensional arrays
3--FILE--
4<?php
5/* Prototype  : array each(array $arr)
6 * Description: Return the currently pointed key..value pair in the passed array,
7 * and advance the pointer to the next element
8 * Source code: Zend/zend_builtin_functions.c
9 */
10
11/*
12 * Test behaviour of each() when passed:
13 * 1. a two-dimensional array
14 * 2. a sub-array
15 */
16
17echo "*** Testing each() : usage variations ***\n";
18
19$arr = array ('zero',
20              array(1, 2, 3),
21              'one' => 'un',
22              array('a', 'b', 'c')
23              );
24
25echo "\n-- Pass each() a two-dimensional array --\n";
26for ($i = 1; $i < count($arr); $i++) {
27	var_dump( each($arr) );
28}
29
30echo "\n-- Pass each() a sub-array --\n";
31var_dump( each($arr[2]));
32
33echo "Done";
34?>
35
36--EXPECTF--
37*** Testing each() : usage variations ***
38
39-- Pass each() a two-dimensional array --
40array(4) {
41  [1]=>
42  string(4) "zero"
43  ["value"]=>
44  string(4) "zero"
45  [0]=>
46  int(0)
47  ["key"]=>
48  int(0)
49}
50array(4) {
51  [1]=>
52  array(3) {
53    [0]=>
54    int(1)
55    [1]=>
56    int(2)
57    [2]=>
58    int(3)
59  }
60  ["value"]=>
61  array(3) {
62    [0]=>
63    int(1)
64    [1]=>
65    int(2)
66    [2]=>
67    int(3)
68  }
69  [0]=>
70  int(1)
71  ["key"]=>
72  int(1)
73}
74array(4) {
75  [1]=>
76  string(2) "un"
77  ["value"]=>
78  string(2) "un"
79  [0]=>
80  string(3) "one"
81  ["key"]=>
82  string(3) "one"
83}
84
85-- Pass each() a sub-array --
86array(4) {
87  [1]=>
88  string(1) "a"
89  ["value"]=>
90  string(1) "a"
91  [0]=>
92  int(0)
93  ["key"]=>
94  int(0)
95}
96Done