Hi all,
Actually i manage to create bbcode function but there is a problem especially with user accidentally mistype the bbcode
For example, if user type the bbcode like this test, it will give an parse error. How do i solve the issue
Here is my bbcode function
function getbbcode($text, $ses="", $filtered)
{
$text = htmlspecialchars($text);
$text=preg_replace("/\[b\](.*?)\[\/b\]/i","<b>\\1</b>", $text);
$text=preg_replace("/\[b\](.*?)\[\/u\]/i","<b>\\1</b>", $text);
$text=preg_replace("/\[i\](.*?)\[\/i\]/i","<i>\\1</i>", $text);
$text=preg_replace("/\[u\](.*?)\[\/u\]/i","<u>\\1</u>", $text);
$text=preg_replace("/\[u\](.*?)\[\/b\]/i","<u>\\1</u>", $text);
$text=preg_replace("/\[big\](.*?)\[\/big\]/i","<big>\\1</big>", $text);
$text=preg_replace("/\[small\](.*?)\[\/small\]/i","<small>\\1</small>", $text);
return $text;
}
I tried belows way to solve the issue:
$text=preg_replace("/\[b\][u\](.*?)\[\/b\][\/u\]/i","<b>\\1</b>", $text);
$text=preg_replace("/\[b\][u\](.*?)\[\/b\]\[\/u\]/i","<b>\\1</b>", $text);
$text=preg_replace("/\[b\]/\[u\](.*?)\[\/b\]\[\/u\]/i","<b>\\1</b>", $text);
but none is working. Anybody can solve the issue?