function bb2html($str) { $str = htmlspecialchars($search, ENT_NOQUOTES); $find = array('#\[ *b *\](.+)\[ */b *\]#is', '#\[ *i *\](.+)\[ */i *\]#is', '#\[ *u *\](.+)\[ */u *\]#is', '#\[ *s *\](.+)\[ */s *\]#is', '#\[ *(colou?r) *= *#([a-f0-9]{3}|[a-f0-9]{6}) *\](.+)[ *\1 *\]#is', '#\[ *quote *\](.+)\[ */quote *\]#is'); $replace = array('\1', '\1', '\1', '\1', '\3', '
\1
'); $str = preg_replace($find, $replace, $str); return $str; }