summaryrefslogtreecommitdiff
path: root/ext/spl/tests/array_001.phpt
blob: b55fcba1fdc1fbc997d5e591dcfbd02c4af74887 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
--TEST--
SPL: ArrayObject
--FILE--
<?php

$ar = array(0=>0, 1=>1);
$ar = new ArrayObject($ar);

var_dump($ar);

$ar[2] = 2;
var_dump($ar[2]);
var_dump($ar["3"] = 3);

var_dump(array_merge((array)$ar, array(4=>4, 5=>5)));

var_dump($ar["a"] = "a");

var_dump($ar);
var_dump($ar[0]);
var_dump($ar[6]);
var_dump($ar["b"]);

unset($ar[1]);
unset($ar["3"]);
unset($ar["a"]);
unset($ar[7]);
unset($ar["c"]);
var_dump($ar);

$ar[] = '3';
$ar[] = 4;
var_dump($ar);

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
object(ArrayObject)#%d (1) {
  ["storage":"ArrayObject":private]=>
  array(2) {
    [0]=>
    int(0)
    [1]=>
    int(1)
  }
}
int(2)
int(3)
array(6) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
  [4]=>
  int(4)
  [5]=>
  int(5)
}
string(1) "a"
object(ArrayObject)#%d (1) {
  ["storage":"ArrayObject":private]=>
  array(5) {
    [0]=>
    int(0)
    [1]=>
    int(1)
    [2]=>
    int(2)
    [3]=>
    int(3)
    ["a"]=>
    string(1) "a"
  }
}
int(0)

Notice: Undefined offset: 6 in %sarray_001.php on line %d
NULL

Notice: Undefined index: b in %sarray_001.php on line %d
NULL

Notice: Undefined offset: 7 in %sarray_001.php on line %d

Notice: Undefined index: c in %sarray_001.php on line %d
object(ArrayObject)#%d (1) {
  ["storage":"ArrayObject":private]=>
  array(2) {
    [0]=>
    int(0)
    [2]=>
    int(2)
  }
}
object(ArrayObject)#%d (1) {
  ["storage":"ArrayObject":private]=>
  array(4) {
    [0]=>
    int(0)
    [2]=>
    int(2)
    [4]=>
    string(1) "3"
    [5]=>
    int(4)
  }
}
===DONE===