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