[FX.php List] URLs in text

Steve Winter steve at bluecrocodile.co.nz
Tue Jan 2 21:51:12 MST 2007


Bob,

Quick Google search threw up;

$str = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a
href=\"\\0\">\\0</a>", $str); 

at http://www.liamdelahunty.com/tips/php_convert_url_to_link.php

which an equally quick test here confirms seems to perform what I think
you want ;-)

Cheers
Steve

> I've got a bulletin board system that i've written and use with my  
> clients, and I'd like to add another feature that is missing.
> 
> When someone posts and includes a URL, it would be great if somehow  
> this URL would automatically be made into a clickable link, a la Mac  
> Mail or other HTML mail programs.
> 
> I'm suspecting that the only way is for me to write code that spots  
> URLs and automatically reformats it to make into a link. Is there an  
> easier way? Is there a PHP encoding command that would take
> 
> here is a link to http://www.cnn.com and turn it into "here is a link  
> to" <a href="http://www.cnn.com">http://www.cnn.com</a>
> 
> Any suggestions most welcome. If anyone's interested, you can see the  
> BBS in action at Crystal Gayle's site, which is http:// 
> www.crystalgayle.com/gayleforce.php
> 
> Thanks,
> 
> Bob Patin
> Longterm Solutions
> bob at longtermsolutions.com
> 615-333-6858
> http://www.longtermsolutions.com
> 
>    CONTACT US VIA INSTANT MESSAGING:
>       AIM or iChat: longterm1954
>       Yahoo: longterm_solutions
>       MSN: tech at longtermsolutions.com
>       ICQ: 159333060
> 
> 
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list




More information about the FX.php_List mailing list