1--TEST--
2serialization: arrays with references to the containing array
3--FILE--
4<?php
5function check(&$a) {
6    var_dump($a);
7    $ser = serialize($a);
8    var_dump($ser);
9
10    $b = unserialize($ser);
11    var_dump($b);
12    $b[0] = "b0.changed";
13    var_dump($b);
14    $b[1] = "b1.changed";
15    var_dump($b);
16    $b[2] = "b2.changed";
17    var_dump($b);
18}
19
20echo "\n\n--- 1 refs container:\n";
21$a = array();
22$a[0] = &$a;
23$a[1] = 1;
24$a[2] = 1;
25check($a);
26
27echo "\n\n--- 1,2 ref container:\n";
28$a = array();
29$a[0] = &$a;
30$a[1] = &$a;
31$a[2] = 1;
32check($a);
33
34echo "\n\n--- 1,2,3 ref container:\n";
35$a = array();
36$a[0] = &$a;
37$a[1] = &$a;
38$a[2] = &$a;
39check($a);
40
41echo "Done";
42?>
43--EXPECT--
44--- 1 refs container:
45array(3) {
46  [0]=>
47  *RECURSION*
48  [1]=>
49  int(1)
50  [2]=>
51  int(1)
52}
53string(56) "a:3:{i:0;a:3:{i:0;R:2;i:1;i:1;i:2;i:1;}i:1;i:1;i:2;i:1;}"
54array(3) {
55  [0]=>
56  &array(3) {
57    [0]=>
58    *RECURSION*
59    [1]=>
60    int(1)
61    [2]=>
62    int(1)
63  }
64  [1]=>
65  int(1)
66  [2]=>
67  int(1)
68}
69array(3) {
70  [0]=>
71  string(10) "b0.changed"
72  [1]=>
73  int(1)
74  [2]=>
75  int(1)
76}
77array(3) {
78  [0]=>
79  string(10) "b0.changed"
80  [1]=>
81  string(10) "b1.changed"
82  [2]=>
83  int(1)
84}
85array(3) {
86  [0]=>
87  string(10) "b0.changed"
88  [1]=>
89  string(10) "b1.changed"
90  [2]=>
91  string(10) "b2.changed"
92}
93
94
95--- 1,2 ref container:
96array(3) {
97  [0]=>
98  *RECURSION*
99  [1]=>
100  *RECURSION*
101  [2]=>
102  int(1)
103}
104string(56) "a:3:{i:0;a:3:{i:0;R:2;i:1;R:2;i:2;i:1;}i:1;R:2;i:2;i:1;}"
105array(3) {
106  [0]=>
107  &array(3) {
108    [0]=>
109    *RECURSION*
110    [1]=>
111    *RECURSION*
112    [2]=>
113    int(1)
114  }
115  [1]=>
116  &array(3) {
117    [0]=>
118    *RECURSION*
119    [1]=>
120    *RECURSION*
121    [2]=>
122    int(1)
123  }
124  [2]=>
125  int(1)
126}
127array(3) {
128  [0]=>
129  &string(10) "b0.changed"
130  [1]=>
131  &string(10) "b0.changed"
132  [2]=>
133  int(1)
134}
135array(3) {
136  [0]=>
137  &string(10) "b1.changed"
138  [1]=>
139  &string(10) "b1.changed"
140  [2]=>
141  int(1)
142}
143array(3) {
144  [0]=>
145  &string(10) "b1.changed"
146  [1]=>
147  &string(10) "b1.changed"
148  [2]=>
149  string(10) "b2.changed"
150}
151
152
153--- 1,2,3 ref container:
154array(3) {
155  [0]=>
156  *RECURSION*
157  [1]=>
158  *RECURSION*
159  [2]=>
160  *RECURSION*
161}
162string(56) "a:3:{i:0;a:3:{i:0;R:2;i:1;R:2;i:2;R:2;}i:1;R:2;i:2;R:2;}"
163array(3) {
164  [0]=>
165  &array(3) {
166    [0]=>
167    *RECURSION*
168    [1]=>
169    *RECURSION*
170    [2]=>
171    *RECURSION*
172  }
173  [1]=>
174  &array(3) {
175    [0]=>
176    *RECURSION*
177    [1]=>
178    *RECURSION*
179    [2]=>
180    *RECURSION*
181  }
182  [2]=>
183  &array(3) {
184    [0]=>
185    *RECURSION*
186    [1]=>
187    *RECURSION*
188    [2]=>
189    *RECURSION*
190  }
191}
192array(3) {
193  [0]=>
194  &string(10) "b0.changed"
195  [1]=>
196  &string(10) "b0.changed"
197  [2]=>
198  &string(10) "b0.changed"
199}
200array(3) {
201  [0]=>
202  &string(10) "b1.changed"
203  [1]=>
204  &string(10) "b1.changed"
205  [2]=>
206  &string(10) "b1.changed"
207}
208array(3) {
209  [0]=>
210  &string(10) "b2.changed"
211  [1]=>
212  &string(10) "b2.changed"
213  [2]=>
214  &string(10) "b2.changed"
215}
216Done
217