
Vader |
Hi Emily this function should achieve what you need done.
function auto_link($content){
$string = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\" target=\"_blank\">\\0</a>", $content);
return $string;
}
echo auto_link($content);
Where content is any page content that you want the urls to become links. Also note that this code will only auto link urls with the http:// so if you simply had www.domain.com it wouldn't link it. This can be particularly useful if you will have URLs on the page that you do not want to be linked.
Vader.
Monday, 9th November 2009
| Votes: |
|
36 |
|
10 |
|