1--TEST--
2Test array_splice() function : usage variations - references
3--FILE--
4<?php
5/*
6 * Function is implemented in ext/standard/array.c
7*/
8
9
10echo "test behaviour when input array is in a reference set\n";
11
12$input_array=array (array(1,2));
13$input_array[]=&$input_array[0];
14var_dump (array_splice ($input_array[0],1,1));
15var_dump ($input_array);
16
17echo "Test behaviour of input arrays containing references \n";
18/*
19 *  There are three regions to test:, before cut, the cut and after the cut.
20 *  For reach we check a plain value, a reference value with integer key and a
21 *  reference value with a string key.
22 */
23$numbers=array(0,1,2,3,4,5,6,7,8,9,10,11,12);
24$input_array=array(0,1,&$numbers[2],"three"=>&$numbers[3],4,&$numbers[5],"six"=>&$numbers[6],7,&$numbers[8],"nine"=>&$numbers[9]);
25var_dump (array_splice ($input_array,4,3));
26var_dump ($input_array);
27
28echo "Test behaviour of replacement array containing references \n";
29
30$three=3;
31$four=4;
32$input_array=array (0,1,2);
33$b=array(&$three,"fourkey"=>&$four);
34array_splice ($input_array,-1,1,$b);
35var_dump ($input_array);
36
37echo "Test behaviour of replacement which is part of reference set \n";
38
39$int=3;
40$input_array=array (1,2);
41$b=&$int;
42
43array_splice ($input_array,-1,1,$b);
44var_dump ($input_array);
45echo "Done\n";
46?>
47--EXPECT--
48test behaviour when input array is in a reference set
49array(1) {
50  [0]=>
51  int(2)
52}
53array(2) {
54  [0]=>
55  &array(1) {
56    [0]=>
57    int(1)
58  }
59  [1]=>
60  &array(1) {
61    [0]=>
62    int(1)
63  }
64}
65Test behaviour of input arrays containing references
66array(3) {
67  [0]=>
68  int(4)
69  [1]=>
70  &int(5)
71  ["six"]=>
72  &int(6)
73}
74array(7) {
75  [0]=>
76  int(0)
77  [1]=>
78  int(1)
79  [2]=>
80  &int(2)
81  ["three"]=>
82  &int(3)
83  [3]=>
84  int(7)
85  [4]=>
86  &int(8)
87  ["nine"]=>
88  &int(9)
89}
90Test behaviour of replacement array containing references
91array(4) {
92  [0]=>
93  int(0)
94  [1]=>
95  int(1)
96  [2]=>
97  &int(3)
98  [3]=>
99  &int(4)
100}
101Test behaviour of replacement which is part of reference set
102array(2) {
103  [0]=>
104  int(1)
105  [1]=>
106  int(3)
107}
108Done
109