There are several link transform routines in the snippets library here, at px.sklar.com, at zend.com, and at sourceforge. I had various problems with all of them. Here is the routine I am using at the moment.
The basic transform is fairly easy; the problem is that I allow users to enter HTML as well as text -- so I do not want to transform URLs that are inside <a href=""> but I do want to transform "naked" URLs.
I think the following code mangles mailto: html, but hardly anyone ever writes that in a bbs message.
// function to transform links and emails into clickable html
function makelinks($input)
{
// first get http:// and etc
$input = eregi_replace("[\"](http://[[:alnum:]#?/&=.,]*)",
" <a href=\"\1\">\1</a>",
$input);
// and at the beginning of a line
$input = eregi_replace("([a-z]://[[:alnum:]#?/&=.,])",
" <a href=\"\1\">\1</a>",
$input);
// then get the email@hosts
$input = eregi_replace("(([a-z0-9_]|\-|\.)+@([[:space:]]*)([[:alnum:]-]))",
"<a href=\"mailto:\1\">\1</a>", $input);
return($input);
}