Annotation of embedaddon/php/ext/pcre/tests/preg_replace_callback.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: preg_replace_callback()
3: --FILE--
4: <?php
5: $input = "plain [indent] deep [indent] [abcd]deeper[/abcd] [/indent] deep [/indent] plain";
6:
7: function parseTagsRecursive($input)
8: {
9:
10: $regex = '#\[indent]((?:[^[]|\[(?!/?indent])|(?R))+)\[/indent]#';
11:
12: if (is_array($input)) {
13: $input = '<div style="margin-left: 10px">'.$input[1].'</div>';
14: }
15:
16: return preg_replace_callback($regex, 'parseTagsRecursive', $input);
17: }
18:
19: $output = parseTagsRecursive($input);
20:
21: echo $output, "\n";
22:
23: ?>
24: --EXPECT--
25: plain <div style="margin-left: 10px"> deep <div style="margin-left: 10px"> [abcd]deeper[/abcd] </div> deep </div> plain
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>