Jump to content

[SOLVED] using str_replace to replace email address to ascii


AdRock

Recommended Posts

I am trying to find an easier way to change email addresses into ascii to prevent email harvesters grabbing email address but i'm having problems getting it to work properly.

 

Here is the code

 

<?php

$email = "[email protected]";

$letters = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "@", ".", "-", "_");

$ascii = array("&98;", "&99;", "&100;", "&101;", "&102;", "&103;", "&104;", "&105;", "&106;", "&107;", "&108;", "&109;", "&110;", "&111;", "&112;", "&113;", "&114;", "&115;", "&116;", "&117;", "&118;", "&119;", "&120;", "&121;", "&122;", "&48;", "&49;", "&50;", "&51;", "&52;", "&53;", "&54;", "&55;", "&56;", "&57;", "&64;", "&46;", "&45;", "&95;");

$output  = str_replace($letters, $ascii, $email);

echo $output;

?>

 

and this is the output (nothing like it shouldlook)

 

&&&54;0;&&54;0;&56;;&&&54;0;&&&54;3;&64;;&&54;1;;&&&54;0;&&54;0;&55;;&&&54;0;&&54;0;&56;;&46;&&&54;0;&&&54;3;&64;;&&54;0;;&&&54;0;&&54;0;&&54;1;;&&&54;0;&&54;0;&&&54;3;&64;;;&&64;&57;;&&&54;0;&&&54;3;&64;;&55;;&&&54;0;&&54;0;&&54;0;;&45;&&&54;0;&&&54;3;&64;;&&&54;3;&64;;;&&&54;0;&&54;0;&&54;1;;&&&54;0;&&54;0;&&&54;3;&64;;;

 

I can see several @ signs in the output generated and what is with &&& ?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.