Raiviic Posted October 2, 2006 Report Share Posted October 2, 2006 <? $text=$tmp3[1]; $text_apstrade=preg_replace("(((http://www[^ ]+))|(((www[^ ]+)))|((http[^ ]+)))", "<a target=\"_blank\" style=\"text-decoration: none\" href=\"$0\" ><b>°links </b></a>", $text); $text_apstrade = str_replace("http://www","www", $text_apstrade); $text_apstrade = str_replace("www","http://www", $text_apstrade); print($text_apstrade); ?> vai shads pieraksts ir korekts? Link to comment Share on other sites More sharing options...
bubu Posted October 2, 2006 Report Share Posted October 2, 2006 Vai nav iekavu par daudz tajā regexpā? ((a)) jau ir tas pats, kas (a). Link to comment Share on other sites More sharing options...
Stopp Posted October 2, 2006 Report Share Posted October 2, 2006 strādā ? nez, es lietotu kaut ko šitādu. $text=str_replace("www", "http://www", $text); $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\" target=\"_blank\">\\0</a>", $text); tas pārveidos arī ftp:// utt adreses. nez, varbūt jau preg_replace lietot ir pareizāk, bet es kaut kā esmu ar šito ereg_replace pieradis. Link to comment Share on other sites More sharing options...
Raiviic Posted October 2, 2006 Author Report Share Posted October 2, 2006 bubu: es parbaudishu vai tiesham nav pa daudz Stopp: es pameginashu ari tavu variantu ;) Link to comment Share on other sites More sharing options...
Raiviic Posted October 4, 2006 Author Report Share Posted October 4, 2006 bubu: viss strada ari ar vienam iekavam :) Stopp: tavs variants ar bez prob strada :) Link to comment Share on other sites More sharing options...
GedroX Posted October 4, 2006 Report Share Posted October 4, 2006 $text=str_replace("www", "http://www", $text);$text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\" target=\"_blank\">\\0</a>", $text); Nepareizi apstrādā pilnu adresi http://www.adrese.com: <a href="http://http://www.adrese.lv" target="_blank">http://http://www.adrese.lv</a> Link to comment Share on other sites More sharing options...
Recommended Posts