function bb2html($str) { $str = htmlspecialchars($str, ENT_NOQUOTES); $find = array('#\[ ?b *\](.+)\[ ?/b *\]#isU', '#\[ ?i *\](.+)\[ ?/i *\]#isU', '#\[ ?u *\](.+)\[ ?/u *\]#isU', '#\[ ?s *\](.+)\[ ?/s *\]#isU', '#\[(colou*r)=([a-z0-9]*)\](.*)\[\/\1\]#isU', '#\[ ?quote *\](.+)\[ ?/quote *\]#isU', '#\[ ?list *\](.+)\[ ?/list *\]#isU', '#\[ ?\* *\](.+)#isU', '#\[(size)=([0-9]*)\](.*)\[\/\1\]#isU', '#\[(quote)=([a-z0-9]*)\](.*)\[\/\1\]#isU', '#\[ ?code *\](.+)\[ ?/code *\]#isU', '#\[ ?img *\](.+)\[ ?/img *\]#isU', '/^.*\[url=(https?:\/\/)([^\]]*)\].*\[\/url\].*$/', '/^.*\[url=([^\]]*)\].*\[\/url\].*$/' ); $replace = array('\1', '\1', '\1', '\1', '\3', '
\1
', '', '
  • \1', '\3', '
    \2 wrote:

    \3
    \1', '', '\3', '\3', );