1--TEST--
2Test array_shift() function : usage variations - Referenced 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 how array_shift when passed:
12 * 1. a variable that is referenced to an array
13 * 2. an array that contains a referenced array
14 */
15
16echo "*** Testing array_shift() : usage variations ***\n";
17
18echo "\n-- Variable is referenced array --\n";
19$original_array = array('zero', 'one', 'two');
20$copied_array = &$original_array;
21
22echo "Result: ";
23var_dump(array_shift($copied_array));
24echo "\n\$original_array:\n";
25var_dump($original_array);
26echo "\n\$copied_array:\n";
27var_dump($copied_array);
28
29echo "\n-- Element is referenced array --\n";
30$new_array = array (&$copied_array, 1, 'two');
31echo "Result: ";
32var_dump(array_shift($new_array[0]));
33echo "\n\$new_array:\n";
34var_dump($new_array);
35echo "\n\$copied_array\n";
36var_dump($copied_array);
37
38echo "Done";
39?>
40--EXPECT--
41*** Testing array_shift() : usage variations ***
42
43-- Variable is referenced array --
44Result: string(4) "zero"
45
46$original_array:
47array(2) {
48  [0]=>
49  string(3) "one"
50  [1]=>
51  string(3) "two"
52}
53
54$copied_array:
55array(2) {
56  [0]=>
57  string(3) "one"
58  [1]=>
59  string(3) "two"
60}
61
62-- Element is referenced array --
63Result: string(3) "one"
64
65$new_array:
66array(3) {
67  [0]=>
68  &array(1) {
69    [0]=>
70    string(3) "two"
71  }
72  [1]=>
73  int(1)
74  [2]=>
75  string(3) "two"
76}
77
78$copied_array
79array(1) {
80  [0]=>
81  string(3) "two"
82}
83Done
84