Thanks, but that doesn't allow nested tags (a [b] tag inside of an [i]
tag, for example).
Try this:
<?
function format_text($text)
{
$open="\\[";
$close="\\]";
$pattern=$open."(.)".$close."([^".$open."]+)".$open."/"."(.)".$close;
$temp = $text;
$text = ereg_replace($pattern,'<\1>\2</\3>',$text);
while($temp != $text)
{
$temp = $text;
$text = ereg_replace($pattern,'<\1>\2</\3>',$text);
}
return $text;
}
print format_text('[i] this is a [b]bold[/b] test [/i]');
?>
--
Kyle Gibson
admin(at)frozenonline.com
http://www.frozenonline.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php