xref: /PHP-7.1/ext/pcre/tests/split.phpt (revision 6fb763c4)
1--TEST--
2preg_split()
3--FILE--
4<?php
5
6var_dump(preg_split());
7var_dump(preg_split('/*/', 'x'));
8
9var_dump(preg_split('/[\s, ]+/', 'x yy,zzz'));
10var_dump(preg_split('/[\s, ]+/', 'x yy,zzz', -1));
11var_dump(preg_split('/[\s, ]+/', 'x yy,zzz', 0));
12var_dump(preg_split('/[\s, ]+/', 'x yy,zzz', 1));
13var_dump(preg_split('/[\s, ]+/', 'x yy,zzz', 2));
14
15var_dump(preg_split('/\d*/', 'ab2c3u'));
16var_dump(preg_split('/\d*/', 'ab2c3u', -1, PREG_SPLIT_NO_EMPTY));
17
18?>
19--EXPECTF--
20Warning: preg_split() expects at least 2 parameters, 0 given in %ssplit.php on line 3
21bool(false)
22
23Warning: preg_split(): Compilation failed: nothing to repeat at offset 0 in %ssplit.php on line 4
24bool(false)
25array(3) {
26  [0]=>
27  string(1) "x"
28  [1]=>
29  string(2) "yy"
30  [2]=>
31  string(3) "zzz"
32}
33array(3) {
34  [0]=>
35  string(1) "x"
36  [1]=>
37  string(2) "yy"
38  [2]=>
39  string(3) "zzz"
40}
41array(3) {
42  [0]=>
43  string(1) "x"
44  [1]=>
45  string(2) "yy"
46  [2]=>
47  string(3) "zzz"
48}
49array(1) {
50  [0]=>
51  string(8) "x yy,zzz"
52}
53array(2) {
54  [0]=>
55  string(1) "x"
56  [1]=>
57  string(6) "yy,zzz"
58}
59array(8) {
60  [0]=>
61  string(0) ""
62  [1]=>
63  string(1) "a"
64  [2]=>
65  string(1) "b"
66  [3]=>
67  string(0) ""
68  [4]=>
69  string(1) "c"
70  [5]=>
71  string(0) ""
72  [6]=>
73  string(1) "u"
74  [7]=>
75  string(0) ""
76}
77array(4) {
78  [0]=>
79  string(1) "a"
80  [1]=>
81  string(1) "b"
82  [2]=>
83  string(1) "c"
84  [3]=>
85  string(1) "u"
86}
87