note 42542 added to function.ord

From: Date: Thu, 20 May 2004 18:50:37 +0000
Subject: note 42542 added to function.ord
Groups: php.notes 
Request: Send a blank email to php-notes+get-69882@lists.php.net to get a copy of this message
a useful use of an ord.. <?php /* function mail_mash() a cuter way to foil the spam-bots mail_mash will transform email@address.com into a randomly mixed string of real "o" and encoded "&#111;" characters. it's different each time the page loads, but always presents a valid mailto:email@address.com for a human clicker note: the "mailto:" part is also prepended, mixed in to the randomness, so you don't need to provide that in your html, just <a href="'mail_mash($email_address)'"> your@address.com would output *something like*.. &#109;a&#105;&#108;to:&#121;our&#64;a&#100;&#100;r&#101;ss.&#99; &# 111;&#109; have fun! ;o) (or */ function mail_mash($addy) { $addy = 'mailto:'.$addy; for($i=0;$i<strlen($addy);$i++){ $letters[]=$addy[$i]; } while (list($key, $val) = each($letters)) { $r = rand(0,20); if ($r > 9) { $letters[$key] = '&#'.ord($letters[$key]).';';} } $mashed_email_addy = implode('', $letters); return $mashed_email_addy; }/* end function mail_mash() */ ?> ---- Manual Page -- http://www.php.net/manual/en/function.ord.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42542 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42542&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42542&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#69882) next »