Re: making e-mail link
| From: | richard greene | Date: | Thu, 28 Jun 2001 15:28:12 +0000 |
| Subject: | Re: making e-mail link | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-55503@lists.php.net to get a copy of this message | ||
Bill
I grabed this function from the www.php.net manual and it works great, it
covers all your bases, except that it will show you http://www.something.com
for http://www.something.com or www.something.com. If somone
knows how to
modify it so it would only show www.something.com when linked, that would
be perfect.
// Auto Link HTML
/**
* Function from phpmanual http://www.php.net/
* unoandre@online.no
*/
function getAutoLink($text){
if($GLOBALS["use_AutoLinks"]){
$text =
ereg_replace("((www.)([a-zA-Z0-9@:%_.~#-\?&]+[a-zA-Z0-9@:%_~#\?&/]))",
"http://\\1", $text);
$text =
ereg_replace("((ftp://|http://|https://){2})([a-zA-Z0-9@:%_.~#-\?&]+[a-zA-Z0
-9@:%_~#\?&/])", "http://\\3", $text);
$text =
ereg_replace("(((ftp://|http://|https://){1})[a-zA-Z0-9@:%_.~#-\?&]+[a-zA-Z0
-9@:%_~#\?&/])", "<A HREF=\"\\1\"
TARGET=\"_blank\">\\1</A>", $text);
$text =
ereg_replace("([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})","<A
HREF=\"mailto:\\1\">\\1</A>", $text);
return $text;
}
}
peace
Richard
"bill" <bill@billtron.com> wrote in message
news:3B3B48A4.6D5EE2AF@billtron.com...
> I use this to replace URLs as links:
>
> $text = eregi_replace("(http://[^ ]*)","<a
> href=\"\\1\">\\1</a>",$text);
>
> What can I use to replace email addresses (like "name@mymail.com") as
> e-mail links?
>
> kind regards,
>
> bill hollett
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>