PHPFront

Home > PHP > Convert urls to links
The PHP website created by its users!



Convert urls to links


Author
DescriptionSearches a string and converts all the url's found into clickable links.
RatingThis script has been rated 3/5 (6 votes)

PHP Code


<?PHP

/* makehref(string string,string more); 

the more will put what you want i think in a bug but i solve it.. the space in the end that i put.. if you want can create a better regular expression. i dont want to use my mind now. 
*/ 
function makehref($s,$more) { 
return 
preg_replace("/ $/","",preg_replace("/(http://[ws/.-_]*?)([ <n])/",'\1\2',$s ' ')); 
}

 
makehref("this is only a http://www.teste.com and thisnis another http://true.test.com, but this is a test in http://same.line.com hehe");

?>



Rate it: Print Print

Comments


No comments posted yet.

Name
Website
Your comment