mercredi 8 janvier 2020

PHP check if a variable is equal to one of three other variables

$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.

Aucun commentaire:

Enregistrer un commentaire