1
I have the variable $search_dorms
who returns me Array ( [0] => 1 [1] => 2 )
.
She can return too Array ( [0] => 1 [1] => 2 [2] => 3 )
Or simply Array ( [0] => 1 )
I am trying to check the returned values but without success. I ask for help. The code I am 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 could I check if the values that can be strings or numbers are inside the array $search_dorms
? If you notice, I’m trying to check more than 1 value simultaneously and that’s what’s catching.
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. The "OK again" does not appear.
If you had used the radiobutton I recommended, you wouldn’t have this problem. It would only be to see if it is 1, 2 or 3+ ...
– Bacco
@Bacco that cool who remembered and realized that it was for the same project ... is attentive ... rsrsrs ... radio button can not because it can have multiple choice.
– Marcos Vinicius
The guy want 1 bedroom or 3+ and do not want 2? And it is easy to see that it is the same project, just array vc has a last 5 then kkkk. I think you have to rethink the logic of use. In fact if the guy chooses 2 dormitories, it is pq 1 only does not serve.
– Bacco
rsrsrsrs ... I am learning and very, very much with you ... taking scolds and ear tugs here, I ended up doing this whole project in PHPOO just with your tips.
– Marcos Vinicius
@Bacco is a bit too stupid to think that the guy who scores 1 dorm will score 3 or vice versa more the customer wants so .. patience ...
– Marcos Vinicius
Well, if so, the gambiara is the least of :) - I want to see how you will do the query of the search later. It will be "rolled up".
– Bacco