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');
Written by Eduardo González
Related protips
1 Response
contain error <br />
foreach( $protocols as $p)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Related Tags
#php
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#