2

What is the function in vbulletin that convert bbcode to html ??

I found this : convert_wysiwyg_html_to_bbcode() but it's convert html to bbcode, I want the opposite of this function.

Lokers
  • 103
  • 1
  • 3

2 Answers2

0

You can do this by replacing bbcode with corresponding html tags by using str_replace

function bb2html($text)
{
  $bbcode = array("<", ">",
                "[list]", "[*]", "[/list]", 
                "[img]", "[/img]", 
                "[b]", "[/b]", 
                "[u]", "[/u]", 
                "[i]", "[/i]",
                '[color="', "[/color]",
                "[size=\"", "[/size]",
                '[url="', "[/url]",
                "[mail=\"", "[/mail]",
                "[code]", "[/code]",
                "[quote]", "[/quote]",
                '"]');
  $htmlcode = array("&lt;", "&gt;",
                "<ul>", "<li>", "</ul>", 
                "<img src=\"", "\">", 
                "<b>", "</b>", 
                "<u>", "</u>", 
                "<i>", "</i>",
                "<span style=\"color:", "</span>",
                "<span style=\"font-size:", "</span>",
                '<a href="', "</a>",
                "<a href=\"mailto:", "</a>",
                "<code>", "</code>",
                "<table width=100% bgcolor=lightgray><tr><td bgcolor=white>", "</td></tr></table>",
                '">');
  $newtext = str_replace($bbcode, $htmlcode, $text);
  $newtext = nl2br($newtext);//second pass
  return $newtext;
}
Harikrishnan
  • 9,688
  • 11
  • 84
  • 127
0

I have recently used this bb2html parser to convert calendar events from vBulletin to another platform.

vBulletin uses a class vB_BbCodeParser to do its conversions. In my old vBulletin installation, that is in includes/class_bbcode.php

Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390