Just one question, why did you used this:
while(stripos($text, '') !== false && stripos($text, '') !== false )
{
$b = substr($text, stripos($text, '')+3, stripos($text, '') - stripos($text, '') - 3);
$text = str_ireplace('[b]'.$b.'', '<b>'.$b.'</b>', $text);
}
instead of this...