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 = "test@domain.com";

$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 &&& ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.