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 2 of 2
  1. #1
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts

    Smile if (not US && not CA && not MX) {splat;}

    I've got a rough code that works, but just doesn't look right. I like it because I made it, it's small, and it does what I want, but I'm thinking there's a better way.

    PHP Code:
    if (
    $countryName != "United States" && 
    $countryName != "Canada" && 
    $countryName != "Mexico" 
     {exit;} 
    Is this okay or is there a smaller, more compact version of something like this? I'm killing the page for anyone who IS NOT from those three countries.
    <div> - putting your mind in a box since 1997

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    The only other solution is to use an in_array() function and write those countries to the array. Otherwise, the way you have it is as easy as it gets
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

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