You'll need to use regular expressions: http://www.regular-expressions.info
I guess the easiest way would be to locate a http/https url by something like:
!(https?://.+?)(\s|$)!i
and then just link it to itself:
<a href="URL">URL</a>
I guess the code would look something like:
$string = "hello friends . My site is http://$sitenamefromdb.com";
$string = preg_replace('!(https?://.+?)(\s|$)!i', '<a href="\\1">\\1</a>\\2', $string);
echo $string;
but this is untested code. You could also use parse_url() to attempt to break the url up into bits if you wished.