xref: /PHP-5.3/ext/pcre/tests/preg_replace2.phpt (revision ade487e6)
1--TEST--
2preg_replace()
3--SKIPIF--
4<?php
5if (@preg_match('/./u', '') === false) {
6	die('skip no utf8 support in PCRE library');
7}
8?>
9--FILE--
10<?php
11
12var_dump(preg_replace('', array(), ''));
13
14var_dump(preg_replace(array('/\da(.)/ui', '@..@'), '$1', '12Abc'));
15var_dump(preg_replace(array('/\da(.)/ui', '@(.)@'), '$1', array('x','a2aA', '1av2Ab')));
16
17
18var_dump(preg_replace(array('/[\w]+/'), array('$'), array('xyz', 'bdbd')));
19var_dump(preg_replace(array('/\s+/', '~[b-d]~'), array('$'), array('x y', 'bd bc')));
20
21echo "==done==\n";
22
23?>
24--EXPECTF--
25Warning: preg_replace(): Parameter mismatch, pattern is a string while replacement is an array in %spreg_replace2.php on line 3
26bool(false)
27string(1) "c"
28array(3) {
29  [0]=>
30  string(1) "x"
31  [1]=>
32  string(2) "aA"
33  [2]=>
34  string(2) "vb"
35}
36array(2) {
37  [0]=>
38  string(1) "$"
39  [1]=>
40  string(1) "$"
41}
42array(2) {
43  [0]=>
44  string(3) "x$y"
45  [1]=>
46  string(1) "$"
47}
48==done==
49