6
I have two ifs
which take into account 3 conditions, one of which has multiple possibilities.
I’m doing it like this, but it’s not working:
if (($var1 == $var2) && ($var3 == 1 || 3 || 5 || 7 || 8 || 12) && ($var4 > 16)) {
$var5--;
}
if (($var1 == $var2) && ($var3 == 4 || 6 || 9 || 11) && ($var4 > 15)) {
$var5--;
}
In my tests the script is always taking 2 of $var5
, when it was to take out only 1, because $var3
will never match in both cases. So I guess he’s not considering this condition. I have already researched here, and all the examples I have found show at most two conditions.
What is the correct way to declare several conditions within one if
, and some of these conditions may have multiple possibilities and may use other operators within the ($var3
in the example above). Thanks.
On your first
if
do so:if (($var1 == $var2) && ($var3 == 1 || $var3 == 3 || $var3 == 5 || $var3 == 7 || $var3 == 8 || $var3 == 12) && 
 ($var4 > 16)) {
, apply the same logic in the secondif
.– stderr
Ah, that was it, thanks! Always need to repeat the variable right...
– gustavox