+ Reply to Thread
Results 1 to 2 of 2

Thread: If statment issue

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    7

    If statment issue

    I have that IF statment code that seems not to be working 100% accurate :
    Code:
    if($var != "one" && $var != "two")
    {
        exit('$var must be either one or two');
    }
    It doesn`t throw an error , is there any logical error ?

  2. #2
    You can use that instead of your code :
    Code:
    $possible = Array( "one", "two" );
    if(!in_array($var, $possible) ) {
        echo "$var can be either of: " . implode($possible, ", ");
    }

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

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