note 90868 deleted from function.str-replace by philip

From: Date: Wed, 07 Oct 2009 07:55:07 +0000
Subject: note 90868 deleted from function.str-replace by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-161439@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- I create a little function to transform "User@example.net" [to] "user AT example DOT net" and conversely. <?php function code_mail($email) { if(preg_match('^.+@.+\..{1,5}$', $email)) { //email format $email = str_replace('.', ' DOT ', $email); //replace . by dot $email = str_replace('@', ' AT ', $email); //replace @ by at return $email; } else { //not email format return false; } } function decode_mail($email) { //on décode... $email = str_replace(' DOT ', '.', $email); //replace dot by . $email = str_replace(' AT ', '@', $email); //replace at by @ return $email; } ?>

« previous php.notes (#161439) next »