Re: Create a link where http://
| From: | lallous | Date: | Mon, 29 Jul 2002 13:27:33 +0000 |
| Subject: | Re: Create a link where http:// | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-110154@lists.php.net to get a copy of this message | ||
<?
$mem = "Hello world! http://www.helloworld.com\n
Hello world! ftp://ftp.server.com\n
Hello world www.helloworld.com";
// code starts here
$mem = preg_replace ("/\s+([http:|ftp:]{0,1}\S+\.\S+)/me", "' <A href=\"'.
(ereg('^[http:|ftp:]','\\1')
? '\\1\">\\1</A>'
: 'http://\\1\">http://\\1</A>')",
$mem);
print ($mem);
?>
good luck,
"Jesse Lawrence" <lawrence_jesse@yahoo.ca> wrote in message
news:20020729121233.44517.qmail@web11308.mail.yahoo.com...
> Hello there, I'm putting together a message board, and
> would like to automatically turn any instance of
> http://whatever into a link, without requiring the
> viewers to enter html. I'm thinking regex is probably
> the way to go with this, but I'm not really seeing how
> to do it. If someone could point me towards a
> solution, it would be greatly appreciated.
>
> Thanks very much,
> Jesse Lawrence
> http://soniceast.d2g.ca/jesse/
>
> ______________________________________________________________________
> Post your ad for free now! http://personals.yahoo.ca