Last Updated: February 25, 2016
·
717
· 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 ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Related Tags
#php
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside