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