1--TEST--
2Support for flags in preg_replace_callback(_array)
3--FILE--
4<?php
5
6var_dump(preg_replace_callback('/./', function($matches) {
7    var_dump($matches);
8    return $matches[0][0];
9}, 'abc', -1, $count, PREG_OFFSET_CAPTURE));
10echo "\n";
11
12var_dump(preg_replace_callback_array(
13    ['/./' => function($matches) {
14        var_dump($matches);
15        return $matches[0][0];
16    }],
17    'abc', -1, $count, PREG_OFFSET_CAPTURE)
18);
19echo "\n";
20
21var_dump(preg_replace_callback('/(a)|(b)/', function($matches) {
22    var_dump($matches);
23    return $matches[0];
24}, 'abc', -1, $count, PREG_UNMATCHED_AS_NULL));
25echo "\n";
26
27var_dump(preg_replace_callback_array(
28    ['/(a)|(b)/' => function($matches) {
29        var_dump($matches);
30        return $matches[0];
31    }],
32    'abc', -1, $count, PREG_UNMATCHED_AS_NULL)
33);
34echo "\n";
35
36?>
37--EXPECT--
38array(1) {
39  [0]=>
40  array(2) {
41    [0]=>
42    string(1) "a"
43    [1]=>
44    int(0)
45  }
46}
47array(1) {
48  [0]=>
49  array(2) {
50    [0]=>
51    string(1) "b"
52    [1]=>
53    int(1)
54  }
55}
56array(1) {
57  [0]=>
58  array(2) {
59    [0]=>
60    string(1) "c"
61    [1]=>
62    int(2)
63  }
64}
65string(3) "abc"
66
67array(1) {
68  [0]=>
69  array(2) {
70    [0]=>
71    string(1) "a"
72    [1]=>
73    int(0)
74  }
75}
76array(1) {
77  [0]=>
78  array(2) {
79    [0]=>
80    string(1) "b"
81    [1]=>
82    int(1)
83  }
84}
85array(1) {
86  [0]=>
87  array(2) {
88    [0]=>
89    string(1) "c"
90    [1]=>
91    int(2)
92  }
93}
94string(3) "abc"
95
96array(3) {
97  [0]=>
98  string(1) "a"
99  [1]=>
100  string(1) "a"
101  [2]=>
102  NULL
103}
104array(3) {
105  [0]=>
106  string(1) "b"
107  [1]=>
108  NULL
109  [2]=>
110  string(1) "b"
111}
112string(3) "abc"
113
114array(3) {
115  [0]=>
116  string(1) "a"
117  [1]=>
118  string(1) "a"
119  [2]=>
120  NULL
121}
122array(3) {
123  [0]=>
124  string(1) "b"
125  [1]=>
126  NULL
127  [2]=>
128  string(1) "b"
129}
130string(3) "abc"
131