There are functions to help you accomplish this. Mainly the PHP regular expression functions. Here's one I wrote awhile back:
function makeLinks($db_body)
{
return eregi_replace ( "((ht|f)tps?://[^[:blank:]\r\n]+)", "<a target=\"_blank\" href=\"\\0\">\\0</a>", $db_body);
}
That was a few years ago, so I hope it's not buggy, but if it is, you'll soon be a regex pro and you can fix it ;-)
P.S. Yeah, pattern is a triffle n00bie but as I recall, it got the job done ;-)