Convertendo hyperlinks de string para HTML no PHP

Uma ótima função como solução para geração de hyperlinks automaticamente utilizando o PHP!

Função
function dwsHyperLinks($text){
$text = html_entity_decode($text);
$text = ” ” . $text;
$text = eregi_replace(‘(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)’, ‘<a href=”\\1″ target=_blank>\\1</a>’, $text);
$text = eregi_replace(‘(((f|ht){1}tps://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)’, ‘<a href=”\\1″ target=_blank>\\1</a>’, $text);
$text = eregi_replace(‘([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)’,’\\1<a href=”https://\\2″ target=_blank>\\2</a>’, $text);
$text = eregi_replace(‘([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})’, ‘<a href=”mailto:\\1″ target=_blank>\\1</a>’, $text);
print $text;
}


Utilização
dwsHyperLinks(‘Visite meu site https://blog.dwsanalista.com.br/blog’);
ou
dwsHyperLinks(‘Visite meu site blog.dwsanalista.com.br/blog’);
ou
dwsHyperLinks(‘Visite meu site comfaa@gmail.com’);