preg-replace-callback problem
| From: | Khaled Mamdouh | Date: | Tue, 18 Mar 2008 08:57:23 +0000 |
| Subject: | preg-replace-callback problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-271700@lists.php.net to get a copy of this message | ||
In url
http://www.php.net/manual/en/function.preg-replace-callback.php
I read this example:
<?php$input = "plain [indent] deep [indent] deeper [/indent] deep [/indent]
plain";function parseTagsRecursive($input){ $regex =
'#\[indent]((?:[^[]|\[(?!/?indent])|(?R))+)\[/indent]#'; if (is_array($input)) {
$input = '<div style="margin-left:
10px">'.$input[1].'</div>'; } return
preg_replace_callback($regex, 'parseTagsRecursive', $input);}$output =
parseTagsRecursive($input);echo $output;?>
example does not work if there are more deep statement in var I mean if
$input = "plain [indent] deep [indent] deeper [/indent] deep [/indent] plain
plain [indent] deep [indent] deeper [/indent] deep [/indent] plain
";
it does not work corectly how can I solve this problem
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/