Last Updated: February 25, 2016
·
576
· edumurru

tolinks(); convert urls to link in a string

function tolinks($text){</br>
$protocols = ""http,https,ftp";
= explode(",",$protocols);</br>
foreach($prots as $p) {</br>
$text = preg_replace("#".$p"://([A-z0-9./-]+)#", '<a href="http://$1">$1'</a>', $text);</br>
}</br>
return $text;</br>
}</br></br>
echo tolinks('http://www.paginawebdejemplo.com/carpeta/archivo.html & https://agfasg.com');

1 Response
Add your response

contain error <br />
foreach( $protocols as $p)

over 1 year ago ·