Voilà, j'utilise cette fonction pour convertir des url en lien html cliquable :
Elle fonctionne pas trop mal sauf pour cette url :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 function replaceLinks($text) { # convert support@pogoda.in into # <a href="mailto:support@pogoda.in"> # support@pogoda.in</a> $text = ereg_replace('[-a-z0-9!#$%&\'*+/=?^_`{|}~]+@([.]?[a-zA-Z0-9_/-])*','<a href="mailto:\\0">\\0</a>',$text); # convert http://www.pogoda.in/new_york/eng/ into # <a href="http://pogoda.in/new_york/eng/"> # pogoda.in/new_york/eng/</a> $text = ereg_replace('[a-zA-Z]+://(([.]?[a-zA-Z0-9_/-\?])*)','<a href="\\0">\\1</a>',$text); # convert www.pogoda.in/new_york/eng/ into # <a href="http://www.pogoda.in/new_york/eng/"> # www.pogoda.in/new_york/eng/</a> $text = ereg_replace('(^| )(www([-]*[.]?[a-zA-Z0-9_/-\?&%])*)',' <a href="http://\\2">\\2</a>',$text); return $text; }
En effet, la fonction coupe le lien au niveau du "-". J'arrive pas à trouver d'où cela peut venir au niveau de l'expression régulière.
Une idée ?
--
Site web : www.tux-planet.fr
Partager