PHPBuilder - URL to Hyperlink

RSS Twitter

URL to Hyperlink

by: Roberto Berto
December 1, 2000

Version: 1.0

Type: Function

Category: HTML

License: GNU General Public License

Description: This function searches text for URL's and changes them into hyperlinks ( becomes <a href=></a>. It's especially useful for times when you don't wish to let your visitors use html in forums or other such public areas.


/* 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:\/\/[\w\s\/\.-_]*?)([ <\n])/",'\\1\\2',$s . ' ')); 

 makehref("this is only a and this\nis another, but this is a test in hehe");


Comment and Contribute

Your comment has been submitted and is pending approval.

Roberto Berto



(Maximum characters: 1200). You have characters left.