//لتفعيلـ الروابط و الإيميلات تلقائيــاfunction Auto_link ($text) {
// For http
$text = str_replace("http://www.","www.",$text);
$text = str_replace("www.","http://www.",$text);
$text = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<A TARGET=\"_blank\" HREF=\"$0\">$0</A>", $text);
// For mail
$text = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<A HREF=\"mailto:$0\">$0</A>",$text);
return $text;
}// طريقة الاستدعاء
$txty = "http://www.traidnt.net ... webmaster@traidnt.com";
$txt_link = Auto_link($txty);
echo "<p> <b>".$txt_link."</b></p>";
// For http
$text = str_replace("http://www.","www.",$text);
$text = str_replace("www.","http://www.",$text);
$text = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<A TARGET=\"_blank\" HREF=\"$0\">$0</A>", $text);
// For mail
$text = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<A HREF=\"mailto:$0\">$0</A>",$text);
return $text;
}// طريقة الاستدعاء
$txty = "http://www.traidnt.net ... webmaster@traidnt.com";
$txt_link = Auto_link($txty);
echo "<p> <b>".$txt_link."</b></p>";
ليست هناك تعليقات:
إرسال تعليق