Código PHP:
function unBBcode($texto){
$texto = html_entity_decode($texto);
$a = array(
"/\<i\>(.*?)\<\/i\>/is",
"/\<b\>(.*?)\<\/b\>/is",
"/\<u\>(.*?)\<\/u\>/is",
"/\<center\>(.*?)\<\/center\>/is",
"/\<left\>(.*?)\<\/left\>/is",
"/\<right\>(.*?)\<\/right\>/is",
"/\<img\>(.*?)\<\/img\>/is",
"/\<url=(.*?)\>(.*?)\<\/url\>/is",
"/\<url>(.*?)\<\/url\>/is",
"/\<quote=(.*?)\>(.*?)\<\/quote\>/is",
"/\<quote>(.*?)\<\/quote\>/is",
"/\<br \>/is"
);
$b = array(
"[i]$1[/i]",
"[b]$1[/b]",
"[u]$1[/u]",
"[center]$1[/center]",
"[left]$1[/left]",
"[right]$1[/right]",
"[img src=\"$1\" /]",
"[a href=\"$1\"]$2[/a]",
"[a href=\"$1\"]$1[/a]",
"[div class=\"quote\"]Cita:[br/] [div class=\"bgquote\"]Empezado por: [b]$1[/b][br/] [font style=\"font-size:10px;\"][i]$2[/i][/font][/div][/div]",
"[div class=\"quote\"]Cita:[br/] [div class=\"bgquote\"]Empezado por alguién:[br/] [font style=\"font-size:10px;\"][i]$1[/i][/font][/div][/div]",
""
);
$texto = preg_replace($a, $b, $texto);
return $texto;
}