xref: /PHP-7.3/ext/pcre/tests/split2.phpt (revision 661bce47)
1--TEST--
2preg_split() 2nd test
3--INI--
4pcre.jit=0
5--FILE--
6<?php
7
8var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_DELIM_CAPTURE));
9var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_OFFSET_CAPTURE));
10var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE));
11var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE));
12var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE));
13var_dump(preg_split('/(\d*)/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE));
14
15
16var_dump(preg_last_error(1));
17ini_set('pcre.recursion_limit', 1);
18var_dump(preg_last_error() == PREG_NO_ERROR);
19var_dump(preg_split('/(\d*)/', 'ab2c3u'));
20var_dump(preg_last_error() == PREG_RECURSION_LIMIT_ERROR);
21
22?>
23--EXPECTF--
24array(15) {
25  [0]=>
26  string(0) ""
27  [1]=>
28  string(0) ""
29  [2]=>
30  string(1) "a"
31  [3]=>
32  string(0) ""
33  [4]=>
34  string(1) "b"
35  [5]=>
36  string(1) "2"
37  [6]=>
38  string(0) ""
39  [7]=>
40  string(0) ""
41  [8]=>
42  string(1) "c"
43  [9]=>
44  string(1) "3"
45  [10]=>
46  string(0) ""
47  [11]=>
48  string(0) ""
49  [12]=>
50  string(1) "u"
51  [13]=>
52  string(0) ""
53  [14]=>
54  string(0) ""
55}
56array(8) {
57  [0]=>
58  array(2) {
59    [0]=>
60    string(0) ""
61    [1]=>
62    int(0)
63  }
64  [1]=>
65  array(2) {
66    [0]=>
67    string(1) "a"
68    [1]=>
69    int(0)
70  }
71  [2]=>
72  array(2) {
73    [0]=>
74    string(1) "b"
75    [1]=>
76    int(1)
77  }
78  [3]=>
79  array(2) {
80    [0]=>
81    string(0) ""
82    [1]=>
83    int(3)
84  }
85  [4]=>
86  array(2) {
87    [0]=>
88    string(1) "c"
89    [1]=>
90    int(3)
91  }
92  [5]=>
93  array(2) {
94    [0]=>
95    string(0) ""
96    [1]=>
97    int(5)
98  }
99  [6]=>
100  array(2) {
101    [0]=>
102    string(1) "u"
103    [1]=>
104    int(5)
105  }
106  [7]=>
107  array(2) {
108    [0]=>
109    string(0) ""
110    [1]=>
111    int(6)
112  }
113}
114array(6) {
115  [0]=>
116  string(1) "a"
117  [1]=>
118  string(1) "b"
119  [2]=>
120  string(1) "2"
121  [3]=>
122  string(1) "c"
123  [4]=>
124  string(1) "3"
125  [5]=>
126  string(1) "u"
127}
128array(4) {
129  [0]=>
130  array(2) {
131    [0]=>
132    string(1) "a"
133    [1]=>
134    int(0)
135  }
136  [1]=>
137  array(2) {
138    [0]=>
139    string(1) "b"
140    [1]=>
141    int(1)
142  }
143  [2]=>
144  array(2) {
145    [0]=>
146    string(1) "c"
147    [1]=>
148    int(3)
149  }
150  [3]=>
151  array(2) {
152    [0]=>
153    string(1) "u"
154    [1]=>
155    int(5)
156  }
157}
158array(15) {
159  [0]=>
160  array(2) {
161    [0]=>
162    string(0) ""
163    [1]=>
164    int(0)
165  }
166  [1]=>
167  array(2) {
168    [0]=>
169    string(0) ""
170    [1]=>
171    int(0)
172  }
173  [2]=>
174  array(2) {
175    [0]=>
176    string(1) "a"
177    [1]=>
178    int(0)
179  }
180  [3]=>
181  array(2) {
182    [0]=>
183    string(0) ""
184    [1]=>
185    int(1)
186  }
187  [4]=>
188  array(2) {
189    [0]=>
190    string(1) "b"
191    [1]=>
192    int(1)
193  }
194  [5]=>
195  array(2) {
196    [0]=>
197    string(1) "2"
198    [1]=>
199    int(2)
200  }
201  [6]=>
202  array(2) {
203    [0]=>
204    string(0) ""
205    [1]=>
206    int(3)
207  }
208  [7]=>
209  array(2) {
210    [0]=>
211    string(0) ""
212    [1]=>
213    int(3)
214  }
215  [8]=>
216  array(2) {
217    [0]=>
218    string(1) "c"
219    [1]=>
220    int(3)
221  }
222  [9]=>
223  array(2) {
224    [0]=>
225    string(1) "3"
226    [1]=>
227    int(4)
228  }
229  [10]=>
230  array(2) {
231    [0]=>
232    string(0) ""
233    [1]=>
234    int(5)
235  }
236  [11]=>
237  array(2) {
238    [0]=>
239    string(0) ""
240    [1]=>
241    int(5)
242  }
243  [12]=>
244  array(2) {
245    [0]=>
246    string(1) "u"
247    [1]=>
248    int(5)
249  }
250  [13]=>
251  array(2) {
252    [0]=>
253    string(0) ""
254    [1]=>
255    int(6)
256  }
257  [14]=>
258  array(2) {
259    [0]=>
260    string(0) ""
261    [1]=>
262    int(6)
263  }
264}
265array(6) {
266  [0]=>
267  array(2) {
268    [0]=>
269    string(1) "a"
270    [1]=>
271    int(0)
272  }
273  [1]=>
274  array(2) {
275    [0]=>
276    string(1) "b"
277    [1]=>
278    int(1)
279  }
280  [2]=>
281  array(2) {
282    [0]=>
283    string(1) "2"
284    [1]=>
285    int(2)
286  }
287  [3]=>
288  array(2) {
289    [0]=>
290    string(1) "c"
291    [1]=>
292    int(3)
293  }
294  [4]=>
295  array(2) {
296    [0]=>
297    string(1) "3"
298    [1]=>
299    int(4)
300  }
301  [5]=>
302  array(2) {
303    [0]=>
304    string(1) "u"
305    [1]=>
306    int(5)
307  }
308}
309
310Warning: preg_last_error() expects exactly 0 parameters, 1 given in %s on line %d
311NULL
312bool(true)
313bool(false)
314bool(true)
315