Nel tutorial di oggi imparerete come creare una funzione che aggiunge automaticamente il link mailto a un indirizzo email contenuto in una stringa.
$stringa = linkMailTo("This should format my email address example@domain.com"); function linkMailTo($stringa) { $pattern = "/([a-z0-9][_a-z0-9.-]+@([0-9a-z][_0-9a-z-]+\.)+[a-z]{2,6})/i"; $replace = "\\1"; $text = preg_replace($pattern, $replace, $stringa); return htmlspecialchars($text); }



Leave Your Response