xref: /PHP-5.6/ext/spl/tests/array_001.phpt (revision 610c7fbe)
1--TEST--
2SPL: ArrayObject
3--FILE--
4<?php
5
6$ar = array(0=>0, 1=>1);
7$ar = new ArrayObject($ar);
8
9var_dump($ar);
10
11$ar[2] = 2;
12var_dump($ar[2]);
13var_dump($ar["3"] = 3);
14
15var_dump(array_merge((array)$ar, array(4=>4, 5=>5)));
16
17var_dump($ar["a"] = "a");
18
19var_dump($ar);
20var_dump($ar[0]);
21var_dump($ar[6]);
22var_dump($ar["b"]);
23
24unset($ar[1]);
25unset($ar["3"]);
26unset($ar["a"]);
27unset($ar[7]);
28unset($ar["c"]);
29var_dump($ar);
30
31$ar[] = '3';
32$ar[] = 4;
33var_dump($ar);
34
35?>
36===DONE===
37<?php exit(0); ?>
38--EXPECTF--
39object(ArrayObject)#%d (1) {
40  ["storage":"ArrayObject":private]=>
41  array(2) {
42    [0]=>
43    int(0)
44    [1]=>
45    int(1)
46  }
47}
48int(2)
49int(3)
50array(6) {
51  [0]=>
52  int(0)
53  [1]=>
54  int(1)
55  [2]=>
56  int(2)
57  [3]=>
58  int(3)
59  [4]=>
60  int(4)
61  [5]=>
62  int(5)
63}
64string(1) "a"
65object(ArrayObject)#%d (1) {
66  ["storage":"ArrayObject":private]=>
67  array(5) {
68    [0]=>
69    int(0)
70    [1]=>
71    int(1)
72    [2]=>
73    int(2)
74    [3]=>
75    int(3)
76    ["a"]=>
77    string(1) "a"
78  }
79}
80int(0)
81
82Notice: Undefined offset: 6 in %sarray_001.php on line %d
83NULL
84
85Notice: Undefined index: b in %sarray_001.php on line %d
86NULL
87
88Notice: Undefined offset: 7 in %sarray_001.php on line %d
89
90Notice: Undefined index: c in %sarray_001.php on line %d
91object(ArrayObject)#%d (1) {
92  ["storage":"ArrayObject":private]=>
93  array(2) {
94    [0]=>
95    int(0)
96    [2]=>
97    int(2)
98  }
99}
100object(ArrayObject)#%d (1) {
101  ["storage":"ArrayObject":private]=>
102  array(4) {
103    [0]=>
104    int(0)
105    [2]=>
106    int(2)
107    [4]=>
108    string(1) "3"
109    [5]=>
110    int(4)
111  }
112}
113===DONE===
114