par
Victor BRITO » 06 janv. 2008, 01:22
Essaie ce code :
$texte = '[url]www.lesite.fr[/url]';
$texte_html = preg_replace ("#\[url\](.)+?\[/url\]#i", '<a href="http://\\1">\\1</a>', $texte);
// Si le BBCode contient déjà un http:// ou un https://, suppression du doublon
$texte_html = preg_replace ("#http://(https?://)#i", '\\1', $texte_html);
Essaie ce code :
[php]$texte = '[url]www.lesite.fr[/url]';
$texte_html = preg_replace ("#\[url\](.)+?\[/url\]#i", '<a href="http://\\1">\\1</a>', $texte);
// Si le BBCode contient déjà un http:// ou un https://, suppression du doublon
$texte_html = preg_replace ("#http://(https?://)#i", '\\1', $texte_html);
[/php]