Revision: 38853
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 8, 2011 22:50 by ZaiSL
Initial Code
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("<", ">", "<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; }
Initial URL
Initial Description
Simply call the function by passing your string you wish to parse. To convert the parser to HTML to BB Code, change this line: $newtext = str_replace($bbcode, $htmlcode, $text); to $newtext = str_replace($htmlcode, $bbcode, $text);
Initial Title
BB Code to HTML
Initial Tags
Initial Language
PHP