note 42542 modified in function.ord by tomsommer
| From: | tomsommer@php.net | Date: | Thu, 10 Jun 2004 18:34:21 +0000 |
| Subject: | note 42542 modified in function.ord by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-70896@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 "o" 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="<?php echo mail_mash($email_address); ?>">
your@address.com
would output *something like*..
mailto:your@address.c
&# 111;m
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() */
?>
--was--
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 "o" 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*..
mailto:your@address.c
&# 111;m
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() */
?>
http://www.php.net/manual/en/function.ord.php