xref: /PHP-8.3/ext/pcre/tests/request47456.phpt (revision cb28a0ab)
1--TEST--
2Request #47456 (Missing PCRE option 'J')
3--DESCRIPTION--
4The J modifier is supposed to be identical to the internal option (?J), so we're
5testing both.
6--FILE--
7<?php
8preg_match_all('/(?J)(?<chr>[ac])(?<num>\d)|(?<chr>[b])/', 'a1bc3', $m, PREG_SET_ORDER);
9var_dump($m);
10
11unset($m);
12preg_match_all('/(?<chr>[ac])(?<num>\d)|(?<chr>[b])/J', 'a1bc3', $m, PREG_SET_ORDER);
13var_dump($m);
14?>
15--EXPECT--
16array(3) {
17  [0]=>
18  array(5) {
19    [0]=>
20    string(2) "a1"
21    ["chr"]=>
22    string(1) "a"
23    [1]=>
24    string(1) "a"
25    ["num"]=>
26    string(1) "1"
27    [2]=>
28    string(1) "1"
29  }
30  [1]=>
31  array(6) {
32    [0]=>
33    string(1) "b"
34    ["chr"]=>
35    string(1) "b"
36    [1]=>
37    string(0) ""
38    ["num"]=>
39    string(0) ""
40    [2]=>
41    string(0) ""
42    [3]=>
43    string(1) "b"
44  }
45  [2]=>
46  array(5) {
47    [0]=>
48    string(2) "c3"
49    ["chr"]=>
50    string(1) "c"
51    [1]=>
52    string(1) "c"
53    ["num"]=>
54    string(1) "3"
55    [2]=>
56    string(1) "3"
57  }
58}
59array(3) {
60  [0]=>
61  array(5) {
62    [0]=>
63    string(2) "a1"
64    ["chr"]=>
65    string(1) "a"
66    [1]=>
67    string(1) "a"
68    ["num"]=>
69    string(1) "1"
70    [2]=>
71    string(1) "1"
72  }
73  [1]=>
74  array(6) {
75    [0]=>
76    string(1) "b"
77    ["chr"]=>
78    string(1) "b"
79    [1]=>
80    string(0) ""
81    ["num"]=>
82    string(0) ""
83    [2]=>
84    string(0) ""
85    [3]=>
86    string(1) "b"
87  }
88  [2]=>
89  array(5) {
90    [0]=>
91    string(2) "c3"
92    ["chr"]=>
93    string(1) "c"
94    [1]=>
95    string(1) "c"
96    ["num"]=>
97    string(1) "3"
98    [2]=>
99    string(1) "3"
100  }
101}
102