berta Posted March 20, 2008 Report Share Posted March 20, 2008 Ka pareizi parverst linkus no teksta uz hyperlinku? jaalinkojas buutu shados gadijumos: http://lapa.lv http://www.lapa.lv http://kkas.lapa.lv www.lapa.lv Pagaidam ir shadi divi varianti function text_url($t){ $t = preg_replace("/(http:\/\/|www\.)([^\s]*)(\.[a-z]{2,6})([^\s]*)/i", '<a href="http://$2$3$4">$2$3$4</a>', $t); return $t; } function text_url2($t){ $t = preg_replace("/(http:\/\/www\.|http:\/\/|www\.)([^\s]*)(\.[a-z]{2,6})([^\s]*)/i", '<a href="http://www.$2$3$4" >$2$3$4</a>', $t); return $t; } Pirmaja gadijuma www.lapa.lv paariet uz http://lapa.lv , las daudzos gadijumos nestradatu. Otrajaa gadijumaa http://blog.lapa.lv pariet uz http://www.blog.lapa.lv , kas pilnigi noteikti nestradaas. Vai vispar ir kads universals risinajums visiem gadijumiem? Jau ieprieksh, paldies Link to comment Share on other sites More sharing options...
xPtv45z Posted March 20, 2008 Report Share Posted March 20, 2008 http://lv.php.net/manual/en/function.preg-replace.php#80877 Link to comment Share on other sites More sharing options...
berta Posted March 20, 2008 Author Report Share Posted March 20, 2008 Paldies par linku. Piemers gan ari nebija pilnigs, jo pie atsevishkiem simboliem noraava beigas. Pietika ar ideju, ka funkcijaa jaaieliek divi pregmachi, viens paarbauda saakumu uz http:// , otrs uz www. Job's done. Link to comment Share on other sites More sharing options...
Recommended Posts