1--TEST--
2Test array_shift() function : usage variations - multi-dimensional arrays
3--FILE--
4<?php
5/* Prototype  : mixed array_shift(array &$stack)
6 * Description: Pops an element off the beginning of the array
7 * Source code: ext/standard/array.c
8 */
9
10/*
11 * Test popping elements from a sub-array and popping an array from an array
12 */
13
14echo "*** Testing array_shift() : usage variations ***\n";
15
16$stack_first = array(array(1, 2, 3), 'one', 'two');
17$stack_last = array ('zero', 'one', array (1, 2, 3));
18echo "\n-- Before shift: --\n";
19echo "---- \$stack_first:\n";
20var_dump($stack_first);
21echo "---- \$stack_last:\n";
22var_dump($stack_last);
23
24echo "\n-- After shift: --\n";
25echo "---- Pop array from array:\n";
26echo "Returned value:\t";
27var_dump(array_shift($stack_first));
28echo "New array:\n";
29var_dump($stack_first);
30
31echo "---- Pop element from array within array:\n";
32echo "Returned value:\t";
33var_dump(array_shift($stack_last[2]));
34echo "New array:\n";
35var_dump($stack_last);
36
37echo "Done";
38?>
39--EXPECTF--
40*** Testing array_shift() : usage variations ***
41
42-- Before shift: --
43---- $stack_first:
44array(3) {
45  [0]=>
46  array(3) {
47    [0]=>
48    int(1)
49    [1]=>
50    int(2)
51    [2]=>
52    int(3)
53  }
54  [1]=>
55  string(3) "one"
56  [2]=>
57  string(3) "two"
58}
59---- $stack_last:
60array(3) {
61  [0]=>
62  string(4) "zero"
63  [1]=>
64  string(3) "one"
65  [2]=>
66  array(3) {
67    [0]=>
68    int(1)
69    [1]=>
70    int(2)
71    [2]=>
72    int(3)
73  }
74}
75
76-- After shift: --
77---- Pop array from array:
78Returned value:	array(3) {
79  [0]=>
80  int(1)
81  [1]=>
82  int(2)
83  [2]=>
84  int(3)
85}
86New array:
87array(2) {
88  [0]=>
89  string(3) "one"
90  [1]=>
91  string(3) "two"
92}
93---- Pop element from array within array:
94Returned value:	int(1)
95New array:
96array(3) {
97  [0]=>
98  string(4) "zero"
99  [1]=>
100  string(3) "one"
101  [2]=>
102  array(2) {
103    [0]=>
104    int(2)
105    [1]=>
106    int(3)
107  }
108}
109Done