Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default PHP cleanEmail Function Error?

    Before you say cleanEmail(); function doesn't exist, it's a custom one.
    What it does is when the user types in their email it changes @'s to [at]'s and .'s to [dot]'s. Anyone who's made use of php.net will know what I'm trying to do. The reason for doing this is to stop SPAM bots scanning the memberlist pages to grab people's emails. You may think about using this yourselves.
    Note I'm very new to functions and please forgive me if it's a really stupid error.

    Here's my code for the function.
    PHP Code:
    <?php

    function cleanEmail($var)
    {

    $find[0] = "/./";
    $find[1] = "/@/";
    $replace[0] = " [dot] ";
    $replace[1] = " [at] ";
    ksort($find);
    ksort($replace);

    preg_replace($find$replace$var);

    return 
    $var;

    }

    echo 
    cleanEmail("[email protected]");
    ?>
    And it just echo's out the unclean email which is [email protected] when it should be echo-ing out someone [at] domain [dot] ext. Any help or fixes appreciated.
    Last edited by lolwut; 23-10-2007 at 09:45 PM.
    i've been here for over 8 years and i don't know why

  2. #2
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default

    Sorry for the double but I couldn't edit above.
    It does work if you comment out the lines that change a . to a [dot], hope that helps in some way? :S
    i've been here for over 8 years and i don't know why

  3. #3
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    EDIT: Here you go:

    PHP Code:
    <?php

    function cleanEmail($var)
    {

    $find = array("/\./""/@/");
    $replace = array(" [dot] "" [at] ");

    $var preg_replace($find$replace$var);

    return 
    $var;

    }

    echo 
    cleanEmail("[email protected]");
    ?>
    Last edited by Invent; 23-10-2007 at 10:23 PM.

  4. #4
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default

    Thanks alot Simon :]! +Reps. Thread closed as fixed.
    Last edited by lolwut; 23-10-2007 at 10:29 PM.
    i've been here for over 8 years and i don't know why

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •