Leif K-Brooks wrote:
I'm working on adding simple BBCode to my site. I'm currently using the [i] tag for testing, with the following code:

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

But it prints "<i>This[/i] is a [i]test</i>". Is there a better way to do this?

<?
function bbcode($text)
{
	$text = str_replace("[","<",$text);
	$text = str_replace("]",">",$text);
	return $text;
}

print bbcode("[i]This[/i] is a [i]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

Reply via email to