Es algo larga (creo que el de [ url=asdas] tambien está mal >.<)
function bbcode ($texto) {
//[spoiler]
$texto = str_replace('[/spoiler]', '</div>', $texto);
$explode = explode('[spoiler]', $texto);
$count = count($explode);
$texto = '';
for($i=0;$i<=$count;$i++) {
$texto += $explode[$i].'<input type="submit" onclick="capa('.$i.')" value="Contenido Oculto">
<div id="capa'.$i.'" style="border:solid #6699FF 1px;background:#B2E0F0; width:480px; display:none;">';
}
//[PHP]
$texto = preg_replace("(\[php\](.+?)\[\/php])ise","colorea('$1')",$texto);
//Negrita
$texto = eregi_replace("\\[b]([^\\[]*)\\[/b]", '<b>\\1</b>', $texto);
//Inclinada
$texto = eregi_replace("\\[i]([^\\[]*)\\[/i]", '<i>\\1</i>', $texto);
//Subrallada
$texto = eregi_replace("\\[u]([^\\[]*)\\[/u]", '<u>\\1</u>', $texto);
//Tachada
$texto = eregi_replace("\\[s]([^\\[]*)\\[/s]", '<s>\\1</s>', $texto);
//Imagen
$texto = eregi_replace("\\[img ([^\\[]*)\\]([^\\[]*)\\[/img\\]", '<img \\1 src="\\2">', $texto);
$texto = eregi_replace("\\[img\\]([^\\[]*)\\[/img\\]", '<img src="\\1">', $texto);
//Letra centrada
$texto = eregi_replace("\\[center]([^\\[]*)\\[/center]", '<center>\\1</center>', $texto);
//Url
$texto = eregi_replace("\\[url=http://([^\\[]*)\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\">\\2</a>",$texto);
$texto = eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\">\\1</a>",$texto);
//Bajar renglon
$texto = str_replace("\n", "<br>", $texto);
//Caritas
$select = mysql_query("SELECT * FROM foro_smiler");
while($row = mysql_fetch_array($select)) {
$texto = str_replace($row['nombre'], "<img src='$row[imagen]' border='0'", $texto);
}
//Youtube
$texto = eregi_replace("\\[youtube\\](http://([a-zA-Z0-9]+\.)?youtube\\.com/watch\\?v=)?([A-Za-z0-9_-]+)([^\\[]*)?\\[/youtube\\]","<embed src=\"http://www.youtube.com/v/\\3&hl=es&fs=1&color1=0x006699&color2=0x54abd6&border=1\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"transparent\" width=\"400\" height=\"350\"></embed>",$texto);
return $texto;
}