PHP if value is 1 OR 2 then echo

Hey gurus,

I’ve got the following working, but cant get it to work when i want to say if user id is 1 OR 2:

WORKING:

if ($user["id"]!=='1') {
do something
}

NOT WORKING:

if (($user["id"]!=='1') || ($user["id"]!=='2'))  {
do something
}

I’m sure its me being stupid, but any help would be great :slight_smile:

Thanks


if ( $id === 1 || $id === 2 ) {
    echo "ID is 1 or two";
}

No?

sorry, my bad, i meant to write that if id DOES NOT equal 1 or 2, then show. I tried your code and it didnt work for me. it still showed for user ids 1 and 2.

so basically, what i meant to say is:

If the user id is not 1 or 2, then show me some stuff.

So…


if ( ($id != 1) && ($id != 2)) {
}

Try this-

if ( ($id != 1) && ($id != 2)) {
} 

Edit - Opps!! already posted the same suggestion. can not delete it. :frowning: