I have the variable $search_dorms
that returns me Array ( [0] => 1 [1] => 2 )
.
It can also return Array ( [0] => 1 [1] => 2 [2] => 3 )
Or simply Array ( [0] => 1 )
I'm trying to check the returned values but to no avail. I ask for help. The code I'm using is:
if(in_array(array('1'), $search_dorms)) {
$search_dorms = 1;
echo $search_dorms . "<br><br>";
} elseif (in_array(array('1', '2'), $search_dorms)){
$search_dorms = 2;
echo $search_dorms . "<br><br>";
}
How can I check if the values that can be strings or numbers are within array $search_dorms
? If you fix it, I'm trying to check more than 1 value simultaneously and that's what you're getting.
Another way to explain what I said above:
if(in_array(1, $search_dorms)) echo "Ok<br><br>";
if(in_array(array(1, 2), $search_dorms)) echo "Ok novamente<br><br>";
I'm trying to do this check. "Ok again" does not appear.