Re: function that makes http into <ahref
| From: | David Harrison | Date: | Tue, 08 Aug 2000 09:31:38 +0000 |
| Subject: | Re: function that makes http into <ahref | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-10610@lists.php.net to get a copy of this message | ||
Something like this works for me.
<?
function linkurl($string)
{
$pattern =
"((www\.|(http|ftp)://)[-A-Za-z0-9]+(\\.[-A-Za-z0-9]+)+(:[0-9]+)?(/[-^A-Za-z0-9_~\#/]*)?([./][-^A-Za-z0-9_~\#/]+)*)";
if (eregi($pattern, $string, $ret))
{
$retval = str_replace($ret[1], "<A
HREF=\"$ret[1]\">$ret[1]</A>", $string);
return($retval);
}
}
$val = linkurl("This is a test string http://www.test.com/test.html test string");
print "Returned: $val\n";
?>
----- Original Message -----
From: "Peter Van Dijck" <peter@vardus.com>
To: <php-general@lists.php.net>
Sent: Tuesday, August 08, 2000 6:47 PM
Subject: [PHP] function that makes http into <ahref
> Anyone got a function that parses a text string and turns everything that
> looks like a url into a clickable url?
>
> thanks girls and guys,
> Peter
>
>
> --
> 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
>
>