جداسازی آدرس ها از متن و تبدیل به لینک :
کد PHP:
<?php
function to_link($string){
return preg_replace("~(http|https|ftp|ftps)://(.*?)(\s|\n|[,.?!](\s|\n)|$)~", '<a href="$1://$2">$1://$2</a>$3',$string);
}
$html = 'This line of text has three urls: http://webhostingtalk.ir http://yahoo.com and http://google.com';
echo to_link($html, TRUE);
?>