Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,466
    Thanks
    15
    Thanked 0 Times in 0 Posts

    debug check email ending

    I have the following code:

    PHP Code:
    list($temail$hostname) = explode("@"$temail); list($name$type) = explode(".",$hostname);

    switch(
    $type)
    {
    case 
    "com";
    case 
    "net";
    case 
    "us";
    case 
    "info";
    case 
    "org";
    case 
    "biz";
     
    $domainvalid=true;  break;
    default;
    $filtered=1;

    what it does is check the email and if the domain is not one on the list then it sets $filtered=1.
    the problem with this is that it is also filetering something like a@a.a.com (wherever there is a subdomain.) how can I fix this?

  • #2
    Regular Coder
    Join Date
    Sep 2005
    Posts
    394
    Thanks
    1
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php
    $address 
    "jim@a.a.com";

    preg_match_all('@(\.[a-z]*)@'$address$matches);

    $tld $matches[0][count($matches[0]) - 1];

    echo 
    $tld//returns .com
    ?>
    You can use your case stuff on $tld.

    ~Phil~

  • #3
    Senior Coder
    Join Date
    May 2004
    Posts
    1,466
    Thanks
    15
    Thanked 0 Times in 0 Posts
    thanks so how would I combine this with teh above to filter all those not in the case.


  •  

    Posting Permissions

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