Thanks, but that doesn't allow nested tags (a [b] tag inside of an [i] tag, for example).

Kyle Gibson wrote:

Thanks a lot, but do you know how to do the same with ereg_replace? I'm trying to learn PCRE, but until I do, I won't be able to add anything to this...

<?php
function bbcode($text){
$text = ereg_replace("(\\[i\\])([^\\[]+)(\\[/i\\])",'<i>\\2</i>',$text);
return $text;
}
print bbcode('[i]This[/i] is a [i]test[/i].');
?>


Works...



--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to