zoiets
<?php
function ubb($bericht)
{
// Enters V
$bericht = str_replace ("[br]","\n",$bericht);
$bericht = str_replace ("\n","<br>",$bericht);
// Code V
$bericht = str_replace ("","<b>Code:</b><br /><table bgcolor=\"#000000\" cellspacing=\"1\" width=\"90%\"><tr><td><table cellpadding=2 cellspacing=\"0\" bgcolor=\"#FFFFFF\" width=\"100%\"><tr><td><font face=Courier size=\"1\" color=\"#000000\">", $bericht);
$bericht = str_replace ("", "</font></td></tr></table></td></tr></table>", $bericht);
// Vet, schuin, etc V
$bericht = preg_replace("/\[b\](.+?)\[\/b\]/is",'<strong>\1</strong>', $bericht);
$bericht = preg_replace("/\[i\](.+?)\[\/i\]/is",'<em>\1</em>', $bericht);
$bericht = preg_replace("/\[u\](.+?)\[\/u\]/is",'<u>\1</u>', $bericht);
$bericht = preg_replace("/\[s\](.+?)\[\/s\]/is",'<s>\1</s>', $bericht);
// Marquee
$bericht = str_replace ("[move]", "<div align=\"center\"><marquee width=\"90%\">", $bericht);
$bericht = str_replace ("[/move]", "</marquee></div>", $bericht);
// Color, font & size V
$bericht = preg_replace ("#\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]#si", "<font color=\"\\1\">\\2</font>", $bericht);
$bericht = preg_replace ("/\[font=(.*)\](.*)\[\/font\]/", "<font face=\"$1\">$2</font>", $bericht);
$bericht = preg_replace ("/\[size=(.*)\](.*)\[\/size\]/", "<font size=\"$1\">$2</font>", $bericht);
// Plaatje toevoegen V
$bericht = preg_replace("/\[img\](.*?)\[\/img\]/si", "<img src=\"\\1\" border=\"0\">",$bericht);
// Diversen V
$bericht = str_replace ("[tt]", "<tt>", $bericht);
$bericht = str_replace ("[/tt]", "</tt>", $bericht);
$bericht = str_replace ("[left]", "<div align=left>", $bericht);
$bericht = str_replace ("[/left]", "</div>", $bericht);
$bericht = str_replace ("[center]", "<div align=\"center\">", $bericht);
$bericht = str_replace ("[/center]", "</div>", $bericht);
$bericht = str_replace ("[right]", "<div align=\"right\">", $bericht);
$bericht = str_replace ("[/right]", "</div>", $bericht);
$bericht = str_replace ("[sub]", "<sub>", $bericht);
$bericht = str_replace ("[/sub]", "</sub>", $bericht);
$bericht = str_replace ("[sup]", "<sup>", $bericht);
$bericht = str_replace ("[/sup]", "</sup>", $bericht);
$bericht = str_replace ("[fixed]", "<font face=\"Courier New\">", $bericht);
$bericht = str_replace ("[/fixed]", "</font>", $bericht);
$bericht = str_replace ("[[","{{",$bericht);
$bericht = str_replace ("]]","}}",$bericht);
$bericht = str_replace ("|","|",$bericht);
$bericht = str_replace ("[pre]","<pre>",$bericht);
$bericht = str_replace ("[/pre]","</pre>",$bericht);
$bericht = str_replace ("{{","[",$bericht);
$bericht = str_replace ("}}","]",$bericht);
// Horizontale lijn V
$bericht = str_replace ("[hr]","<hr color=\"#000000\" noshade />",$bericht);
// Lijst V
$bericht = str_replace ("
- ","<ul>",$bericht);
$bericht = str_replace (" - ","<li>",$bericht);
$bericht = str_replace ("
","</li></ul>",$bericht);
// Tabel V
$bericht = str_replace ("[table]","<table class=\"main\">",$bericht);
$bericht = str_replace ("[/table]","</table>",$bericht);
$bericht = str_replace ("[tr]","<tr>",$bericht);
$bericht = str_replace ("[/tr]","</tr>",$bericht);
$bericht = str_replace ("[td]","<td>",$bericht);
$bericht = str_replace ("[/td]","</td>",$bericht);
// Smiley's V
// Roll Eyes
$bericht = str_replace ("::)","<img src=\"img/ubbc/rolleyes.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace ("[rolleyes]","<img src=\"img/ubbc/rolleyes.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace ("::-)","<img src=\"img/ubbc/rolleyes.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
// Smile
$bericht = str_replace (":)","<img src=\"img/ubbc/smiley.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace ("[smile]","<img src=\"img/ubbc/smiley.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace (":-)","<img src=\"img/ubbc/smiley.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
// Wink
$bericht = str_replace (";)","<img src=\"img/ubbc/wink.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace ("[wink]","<img src=\"img/ubbc/wink.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace (";-)","<img src=\"img/ubbc/wink.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
}
?>
en dan gebruik je m zo:
<?php
$ubb = 'Een hele leuke teskst met
ubbcodes.'
$html = ubb($ubb);
?>