1--TEST--
2explode() function
3--INI--
4error_reporting=2047
5--SKIPIF--
6<?php
7if (PHP_INT_SIZE != 8) die("skip this test is for 64-bit only");
8?>
9--FILE--
10<?php
11/* From http://bugs.php.net/19865 */
12echo var_export(explode("\1", "a". chr(1). "b". chr(0). "d" . chr(1) . "f" . chr(1). "1" . chr(1) . "d"), TRUE);
13echo "\n";
14echo md5(var_export(explode("\1", "a". chr(1). "b". chr(0). "d" . chr(1) . "f" . chr(1). "1" . chr(1) . "d"), TRUE));
15echo "\n";
16
17try {
18    var_dump(explode("", ""));
19} catch (\ValueError $e) {
20    echo $e->getMessage() . "\n";
21}
22try {
23    var_dump(explode("", NULL));
24} catch (\ValueError $e) {
25    echo $e->getMessage() . "\n";
26}
27try {
28    var_dump(explode(NULL, ""));
29} catch (\ValueError $e) {
30    echo $e->getMessage() . "\n";
31}
32
33var_dump(explode("a", ""));
34var_dump(explode("a", "a"));
35var_dump(explode("a", NULL));
36try {
37    var_dump(explode(NULL, "a"));
38} catch (\ValueError $e) {
39    echo $e->getMessage() . "\n";
40}
41var_dump(explode("abc", "acb"));
42var_dump(explode("somestring", "otherstring"));
43var_dump(explode("somestring", "otherstring", -1));
44var_dump(explode("a", "aaaaaa"));
45var_dump(explode("==", str_repeat("-=".ord(0)."=-", 10)));
46var_dump(explode("=", str_repeat("-=".ord(0)."=-", 10)));
47//////////////////////////////////////
48var_dump(explode(":","a lazy dog:jumps:over:",-1));
49var_dump(explode(":","a lazy dog:jumps:over", -1));
50var_dump(explode(":","a lazy dog:jumps:over", -2));
51var_dump(explode(":","a lazy dog:jumps:over:",-4));
52var_dump(explode(":","a lazy dog:jumps:over:",-40000000000000));
53var_dump(explode(":^:","a lazy dog:^:jumps::over:^:",-1));
54var_dump(explode(":^:","a lazy dog:^:jumps::over:^:",-2));
55?>
56--EXPECT--
57array (
58  0 => 'a',
59  1 => 'b' . "\0" . 'd',
60  2 => 'f',
61  3 => '1',
62  4 => 'd',
63)
64d6bee42a771449205344c0938ad4f035
65explode(): Argument #1 ($separator) must not be empty
66explode(): Argument #1 ($separator) must not be empty
67explode(): Argument #1 ($separator) must not be empty
68array(1) {
69  [0]=>
70  string(0) ""
71}
72array(2) {
73  [0]=>
74  string(0) ""
75  [1]=>
76  string(0) ""
77}
78array(1) {
79  [0]=>
80  string(0) ""
81}
82explode(): Argument #1 ($separator) must not be empty
83array(1) {
84  [0]=>
85  string(3) "acb"
86}
87array(1) {
88  [0]=>
89  string(11) "otherstring"
90}
91array(0) {
92}
93array(7) {
94  [0]=>
95  string(0) ""
96  [1]=>
97  string(0) ""
98  [2]=>
99  string(0) ""
100  [3]=>
101  string(0) ""
102  [4]=>
103  string(0) ""
104  [5]=>
105  string(0) ""
106  [6]=>
107  string(0) ""
108}
109array(1) {
110  [0]=>
111  string(60) "-=48=--=48=--=48=--=48=--=48=--=48=--=48=--=48=--=48=--=48=-"
112}
113array(21) {
114  [0]=>
115  string(1) "-"
116  [1]=>
117  string(2) "48"
118  [2]=>
119  string(2) "--"
120  [3]=>
121  string(2) "48"
122  [4]=>
123  string(2) "--"
124  [5]=>
125  string(2) "48"
126  [6]=>
127  string(2) "--"
128  [7]=>
129  string(2) "48"
130  [8]=>
131  string(2) "--"
132  [9]=>
133  string(2) "48"
134  [10]=>
135  string(2) "--"
136  [11]=>
137  string(2) "48"
138  [12]=>
139  string(2) "--"
140  [13]=>
141  string(2) "48"
142  [14]=>
143  string(2) "--"
144  [15]=>
145  string(2) "48"
146  [16]=>
147  string(2) "--"
148  [17]=>
149  string(2) "48"
150  [18]=>
151  string(2) "--"
152  [19]=>
153  string(2) "48"
154  [20]=>
155  string(1) "-"
156}
157array(3) {
158  [0]=>
159  string(10) "a lazy dog"
160  [1]=>
161  string(5) "jumps"
162  [2]=>
163  string(4) "over"
164}
165array(2) {
166  [0]=>
167  string(10) "a lazy dog"
168  [1]=>
169  string(5) "jumps"
170}
171array(1) {
172  [0]=>
173  string(10) "a lazy dog"
174}
175array(0) {
176}
177array(0) {
178}
179array(2) {
180  [0]=>
181  string(10) "a lazy dog"
182  [1]=>
183  string(11) "jumps::over"
184}
185array(1) {
186  [0]=>
187  string(10) "a lazy dog"
188}
189