1--TEST--
2Test current() function : usage variations - multi-dimensional arrays
3--FILE--
4<?php
5/* Prototype  : mixed current(array $array_arg)
6 * Description: Return the element currently pointed to by the internal array pointer
7 * Source code: ext/standard/array.c
8 * Alias to functions: pos
9 */
10
11/*
12 * Test how current() behaves with muti-dimensional and recursive arrays
13 */
14
15echo "*** Testing current() : usage variations ***\n";
16
17echo "\n-- Two Dimensional Array --\n";
18$multi_array = array ('zero', array (1, 2, 3), 'two');
19echo "Initial Position: ";
20var_dump(current($multi_array));
21
22echo "Next Position:    ";
23next($multi_array);
24var_dump(current($multi_array));
25
26echo "End Position:     ";
27end($multi_array);
28var_dump(current($multi_array));
29
30echo "\n-- Access an Array Within an Array --\n";
31//accessing an array within an array
32echo "Initial Position: ";
33var_dump(current($multi_array[1]));
34
35echo "\n-- Recursive, Multidimensional Array --\n";
36//create a recursive array
37$multi_array[] = &$multi_array;
38
39//See where internal pointer is after adding more elements
40echo "Current Position: ";
41var_dump(current($multi_array));
42
43//see if internal pointer is in same position as referenced array
44var_dump(current($multi_array[3][3][3]));
45// see if internal pointer is in the same position from when accessing this inner array
46var_dump(current($multi_array[3][3][3][1]));
47?>
48===DONE===
49--EXPECT--
50*** Testing current() : usage variations ***
51
52-- Two Dimensional Array --
53Initial Position: string(4) "zero"
54Next Position:    array(3) {
55  [0]=>
56  int(1)
57  [1]=>
58  int(2)
59  [2]=>
60  int(3)
61}
62End Position:     string(3) "two"
63
64-- Access an Array Within an Array --
65Initial Position: int(1)
66
67-- Recursive, Multidimensional Array --
68Current Position: string(3) "two"
69string(3) "two"
70int(1)
71===DONE===
72