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--EXPECTF--
36*** Testing each() : usage variations ***
37
38-- Pass each() a two-dimensional array --
39
40Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
41array(4) {
42  [1]=>
43  string(4) "zero"
44  ["value"]=>
45  string(4) "zero"
46  [0]=>
47  int(0)
48  ["key"]=>
49  int(0)
50}
51array(4) {
52  [1]=>
53  array(3) {
54    [0]=>
55    int(1)
56    [1]=>
57    int(2)
58    [2]=>
59    int(3)
60  }
61  ["value"]=>
62  array(3) {
63    [0]=>
64    int(1)
65    [1]=>
66    int(2)
67    [2]=>
68    int(3)
69  }
70  [0]=>
71  int(1)
72  ["key"]=>
73  int(1)
74}
75array(4) {
76  [1]=>
77  string(2) "un"
78  ["value"]=>
79  string(2) "un"
80  [0]=>
81  string(3) "one"
82  ["key"]=>
83  string(3) "one"
84}
85
86-- Pass each() a sub-array --
87array(4) {
88  [1]=>
89  string(1) "a"
90  ["value"]=>
91  string(1) "a"
92  [0]=>
93  int(0)
94  ["key"]=>
95  int(0)
96}
97Done
98