this script will detect URLs in a string and automatically create a link to this URL.
it removes the query-string and shows only the top-level of the site linked to as text.

autolink” makes use of the built-in PHP functions preg_replace( ).

01 <?php
02 
03 $txt = '
04 <p>
05     this is a string with 
06     an url in it http://fundisom.com/g5/ and 
07     its enough to be like that
08 </p>';
09  
10 $txt = preg_replace('/(http|ftp)+(s)?:(\/\/)((\w|\.)+)(\/)?(\S+)?/i', '<a href="\0">\4</a>', $txt);
11  
12 echo $txt;
13  
14 ?>