I have a numeric variable $i. This is a while loop, and $i increments after each iteration.
How can a conditional statement be made as to not be necessary to write such a long statement if($i == 1 || $i == 2 || $i == 25 [...])?
Thanks in advance!
Advertisement
Answer
Use php in_array.
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os)) {
echo "Got Irix";
}