wrapping anchor tags around a URL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I wrote a little function to put anchor tags around a URL. We're using it to make URL's in paragraphs of text linkable:

function link_the_links($s) {
	return preg_replace('@(http://[^\s]+)@sm', '<a href="$1">$1</a>', $s);
}

Its only flaw (besides a goofy name) is that if a link comes at the end of a sentence, right before the period, the period ends up in the link, thus breaking the link. I've got to somehow ignore the trailing period if it is present.

Any ideas?

Richard K Miller

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux