note 61822 deleted from function.str-replace by mazzanet

From: Date: Mon, 13 Feb 2006 09:36:08 +0000
Subject: note 61822 deleted from function.str-replace by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-103610@lists.php.net to get a copy of this message
Note Submitter: marko at dise-web dot com ---- I elaborated a function in PHP a long time ago to resist to the Spam of email (parsing) with the function str_replace(), gives back a result similar to PHP.net Courtesy of http://www.dise-web.com (Marco Antonio Godínez Bustos). <?php function email_replace($correo){ srand((double)microtime()*1000003); $mode = rand(1,5); switch ($mode) { case 1: $at = " at "; $dot = " dot "; break; case 2: $at = " {at} "; $dot = " {dot} "; break; case 3: $at = "_AT_"; $dot = "_DOT_"; break; case 4: $at = " [-AT-] "; $punto = " [-DOT-] "; break; case 5: $at = "at"; $punto = "dot"; endswitch; $correo = str_replace("@",$at,$correo); $correo = str_replace(".",$dot,$correo); return $correo; } # Example: $email = 'user@example.com'; echo email_replace($email); # Will return maybe: # # 1. user at example dot com # 2. user {at} example {dot} com # 3. user_AT_example_DOT_com # 4. user [-AT-] example [-DOT-] com # 5. useratexampledotcom # ?>

« previous php.notes (#103610) next »