c'est bon j'ai trouvé ... un bon code vaut mieux qu'un long discours :
function make_clickable($txt) { $txt = preg_replace('#([^\w=+;%?/]|^)(\w+[\w.-]*\w+@\w+[\w.-]*\w+\.[a-z]{2,4})#i', '$1<a href="mailto:$2"><font color="#0000FF">$2</font></a>', $txt); $txt = preg_replace('#([^\w/@]|^)((?:www\.[\w-]+\.[\w-]+?\S*?)|(?:[a-z]{3,6}://\S+?))(?=[^a-z0-9/]*?(?:[\s<\][]|(?:&(?:quot|lt|gt);)|$))#ei', 'create_link("$1", "$2")', $txt); return $txt; } function create_link($pre, $url) { // these 2 lines fix any apostrophes that get // messed up by being passed to the function $pre = str_replace("\'", "'", $pre); $url = str_replace("\'", "'", $url); $suf = ''; if (preg_match('/&$/', $url)) { $suf = '&'; $url = substr($url, 0, -4); } $html_url = $url; if (!preg_match('#^[a-z]{3,6}://#i', $html_url)) { $html_url = "http://$url"; } return "$pre<a href=\"$html_url\" target=\"_blank\"><font color=\"#0000FF\">$url</font></a>$suf"; }
$valeur = make_clickable($valeur);
voilà ! ca rend les liens cliquables.... très bien !
|