This is what I'm currently using, and it is working for our needs (just in an admin tool), so it doesn't have to be perfect. However I was wondering what other people would do differently:
$row2[6] comes from the sql above...so let's assume here it's a nice variable full of some text =)
$body = stripslashes($row2[6]);
if (eregi("www.",$body) || eregi("http://",$body)) {
$split = split(" ",$body);
for ($i=0; $i<count($split); $i++) {
if (strtolower(substr($split[$i],0,4))=="www." || strtolower(substr($split[$i],0,7))=="http://") {
if (strtolower(substr($split[$i],0,7))=="http://") {
$body_ .= "<a href=\"".$split[$i]."\" target=_blank>".$split[$i]."</a> ";
}
else {
$body_ .= "<a href=\"http://".$split[$i]."\" target=_blank>".$split[$i]."</a> ";
}
}
else {
$body_ .= $split[$i]." ";
}
}
}
if ($body_) $body = $body_;