Here is the simple function that can convert string into clickable links, very easy to use just copy it and paste it where you want to use within you project or you cna modify it accordingly .
function plain_url_to_link($string) {
return preg_replace(
'%(https?|ftp)://([-A-Z0-9./_*?&;=#]+)%i',
'<a target="blank" rel="nofollow" href="$0" target="_blank">$0</a>', $string);
}
Usage
Jus use it as below mention...
$str = "http://www.google.com is a search website, you can also visit http://yahoo.com and http://twitter.com";
echo plain_url_to_link($str);
No comments:
Post a Comment