josef
(usa Ubuntu)
Enviado em 21/07/2013 - 22:54h
Pessoal, to com problema com este eregi_replace, que não fufa no php 5+
Sei que tenho que trocar por preg_match + o i
Mas onde eu insiro o i?
O erro:
function bbcode($text) {
$text=eregi_replace("\\[img\\](http://[^\\[]+)\\[/img\\]","<img src=\"\\1\" border=\"0\">",$text);
$text=eregi_replace("\\[b\\]([^\\[]*)\\[/b\\]","<b>\\1</b>",$text);
$text=eregi_replace("\\[i\\]([^\\[]*)\\[/i\\]","<i>\\1</i>",$text);
$text=eregi_replace("\\[u\\]([^\\[]*)\\[/u\\]","<u>\\1</u>",$text);
$text=eregi_replace("\\[email\\]([^\\[]*)\\[/email\\]","<a href=\"mailto:\\1\">\\1</a>",$text);
$text=eregi_replace("\\[url\\]www.([^\\[]*)\\[/url\\]","<a href=\"http://www.\\1\" target=\"_blank\">www.\\1</a>",$text);
$text=eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=\"_blank\">\\1</a>",$text);
$text=eregi_replace("\\[url=www.([^\\[]+)\\]([^\\[]*)\\[/url\\]","<a href=\"http://www.\\1\" target=\"_blank\">\\2</a>",$text);
$text=eregi_replace("\\[url=http://([^\\[]+)\\]([^\\[]*)\\[/url\\]","<a href=\"http://\\1\" target=\"_blank\">\\2</a>",$text);
$text=eregi_replace("\\[i\\]([^\\[]*)\\[/i\\]","<i>\\1</i>",$text);
$text=eregi_replace("\\[u\\]([^\\[]*)\\[/u\\]","<u>\\1</u>",$text);
$text=eregi_replace("\\[b\\]([^\\[]*)\\[/b\\]","<b>\\1</b>",$text);
return $text;
}
Troco por:
$text=preg_match("\\[img\\](http://[^\\[]+)\\[/img\\]","<img src=\"\\1\" border=\"0\">",$text);
Só não estou conseguindo achar onde o "i"vai...
Grato mesmo
Resolvido:
$text=preg_replace("!\\[img\\](http://[^\\[]+)\\[/img\\]!","<img src=\"\\1\" border=\"0\">/i",$text);