note 71408 deleted from function.str-replace by philip

From: Date: Wed, 07 Oct 2009 08:04:33 +0000
Subject: note 71408 deleted from function.str-replace by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-161460@lists.php.net to get a copy of this message
Note Submitter: Boris DOT Christ AT laposte DOT net ---- I create a little function to transform (to example) "User@example.net" in "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 (#161460) next »