Users can add texts. This texts can have links.
I'd like do add click to it.
The problem is, some links works like:
links that has no http will not work and will become:
http://mywebsite.com/www.example.com
any ideas how to solve it?
function toLink($titulo){
$url = '~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i';
$titulo = preg_replace($url, '<a href="$0" target="_blank" title="$0">$0</a>', $titulo);
return $titulo;
}