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
    New Coder
    Join Date
    Jul 2008
    Posts
    96
    Thanks
    4
    Thanked 0 Times in 0 Posts

    if statement with 2 things?

    I want to make an if statement where there's two criterias thingys lol

    ie:

    PHP Code:
    if ($user_class->admin 1
    But I want it so if admin=2 it displays the same thing

    Help pl0x?
    Last edited by 2Pacalypse; 05-08-2009 at 10:02 PM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    PHP Code:
    if ($user_class->admin == || $user_class->admin == 2
    You can also use a switch on it:
    PHP Code:
    switch ($user_class->admin)
    {
        case 
    1:
        case 
    2:
           
    // Do stuff;
            
    break;

    Or check if its in an array of the 'allowed' I'd guess:
    PHP Code:
    $aAllowed = array(12);
    if (
    in_array($user_class->admin$aAllowed)) 
    I'd go for either the switch or the array, depending on if it can be dynamic or if it is something you'd expect to change frequently (use array if its dynamic, switch if you'll be changing it regularily).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

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