-1
$a = 'cat';
$b = 'dog';
$c = 'bird';
$d = 'cow';

if ($a != ($b || $c || $d)) {
   echo 'none are equal to a';
} else {
   echo 'a is equal to one of them';
}

based on what i want to happend, the if condition should echo "none are equal to a", but my logic has an error, would like some help on how to compare three variables on one if condition.

  • 3
    Is there any reason why `($a != $b) || ($a != $c) || ($a!= $d)` won't work for you? – craq Jan 09 '20 at 02:51

1 Answers1

1

This condition will be true if a is equal to any or more of the three variables.

if($a==$b || $a==$c || $a == $d)
phwt
  • 1,356
  • 1
  • 22
  • 42