Search This Blog

Friday, October 1, 2010

Conver URL to Links

<?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");
?>

No comments:

Post a Comment