1--TEST--
2Test key() function : usage variations
3--FILE--
4<?php
5/*
6 * Test how key() behaves with muti-dimensional and recursive arrays
7 */
8
9echo "*** Testing key() : usage variations ***\n";
10
11echo "\n-- Two Dimensional Array --\n";
12$multi_array = array ('zero', array (1, 2, 3), 'two');
13echo "Initial Position: ";
14var_dump(key($multi_array));
15
16echo "Next Position:    ";
17next($multi_array);
18var_dump(key($multi_array));
19
20echo "End Position:     ";
21end($multi_array);
22var_dump(key($multi_array));
23
24echo "\n-- Access an Array Within an Array --\n";
25//accessing an array within an array
26echo "Initial Position: ";
27var_dump(key($multi_array[1]));
28
29echo "\n-- Recursive, Multidimensional Array --\n";
30//create a recursive array
31$multi_array[] = &$multi_array;
32
33//See where internal pointer is after adding more elements
34echo "Current Position: ";
35var_dump(key($multi_array));
36
37//see if internal pointer is in same position as referenced array
38var_dump(key($multi_array[3][3][3]));
39// see if internal pointer is in the same position from when accessing this inner array
40var_dump(key($multi_array[3][3][3][1]));
41?>
42--EXPECT--
43*** Testing key() : usage variations ***
44
45-- Two Dimensional Array --
46Initial Position: int(0)
47Next Position:    int(1)
48End Position:     int(2)
49
50-- Access an Array Within an Array --
51Initial Position: int(0)
52
53-- Recursive, Multidimensional Array --
54Current Position: int(2)
55int(2)
56int(0)
57