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