php-general | 2001062
Date: 06/30/01
- Next message: Aral Balkan: "[PHP] Help with custom session handler"
- Previous message: Chadwick, Russell: "RE: [PHP] ENC: ADD a user in linux using PHP"
- In reply to: richard greene: "Re: [PHP] making e-mail link"
- Next in thread: Brad Hubbard: "Re: [PHP] making e-mail link"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 29 Jun 2001 01:28, richard greene wrote:
> 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.
How about;
function getAutoLink($text)
{
if( !ereg( "http", $text ) )
{
$text =
ereg_replace("((www.)([a-zA-Z0-9@:%_.~#-\?&]+[a-zA-Z0-9@:%_~#\?&/]))","<A
HREF=\"http://\\1\" TARGET=\"_blank\">\\1</A>", $text);
return $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;
}
Excuse the wrapping butchery.
Cheers,
Brad
-- Brad Hubbard Congo Systems 12 Northgate Drive, Thomastown, Victoria, Australia 3074 Email: brad <email protected> Ph: +61-3-94645981 Fax: +61-3-94645982 Mob: +61-419107559-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Aral Balkan: "[PHP] Help with custom session handler"
- Previous message: Chadwick, Russell: "RE: [PHP] ENC: ADD a user in linux using PHP"
- In reply to: richard greene: "Re: [PHP] making e-mail link"
- Next in thread: Brad Hubbard: "Re: [PHP] making e-mail link"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

