Código PHP:
function bbcodetohtml($texto){
$texto = htmlentities($texto);
$a = array(
"/\[i\](.*?)\[\/i\]/is",
"/\[b\](.*?)\[\/b\]/is",
"/\[u\](.*?)\[\/u\]/is",
"/\[img\](.*?)\[\/img\]/is",
"/\[url\](.*?)\[\/url\]/is",
"/\[url=(.*?)\](.*?)\[\/url\]/is",
"/\[color=(.*?)\](.*?)\[\/color\]/is",
"/\[size=(.*?)\](.*?)\[\/size\]/is"
);
$b = array(
"<i>$1</i>",
"<b>$1</b>",
"<u>$1</u>",
"<img src=\"$1\" />",
"<a href=\"$1\" target=\"_blank\">$1</a>",
"<a href=\"$1\" target=\"_blank\">$2</a>",
"<font color=\"$1\">$2</font>",
"<font size=\"$1\">$2</font>"
);
$texto = preg_replace($a, $b, $texto);
$texto = nl2br($texto);
return $texto;
}
Slds.-