Ho questa funzione che mi serve per riconoscere all'interno del testo un url
codice:
function urlreplace($str){
$str = preg_replace ('((www.|\\WWW.|\\http:|\\HTTP:)+([:/~a-zA-Z0-9_\-\.]+)\.([:/~a-zA-Z0-9/?/=/#/_]+))', '<a target=\'_blank\' href=\'http://$1$2.$3\'>$1$2.$3</a>', $str);
$str = preg_replace ('(([:/~a-zA-Z0-9_\-\.]+)\@([:/~a-zA-Z0-9_\-\.]+))', '<a href=\'mailto:$1@$2\'>$1@$2</a>', $str);
return str_replace("http://http://","http://",$str);
}
Solo che quando nel link ho il carattere & si interrompe (ovvero mi legge il link fino alla & esclusa) e non funziona. Qualcuno sa correggermi questo errore??