Bulk array searching

Ask about a PHP problem here.
Post Reply
User avatar
Posts: 148
Joined: Wed Nov 30, 2011 10:31 pm

Bulk array searching

Post by FrederickGeek8 »

I am trying to create a simple function to validate a query. A query is invalid if in this array, the 3rd to the 10th index are set to N/A. I could is a if statement like this:
[syntax=php]if($array[3] === 'N/A' && $array[4] === 'N/A', etc...)[/syntax]
is there any better way to "bulk" search an array? Maybe something where I could give it a range or something.


EDIT: I was able to do it using:
[syntax=php]if(array_keys($array, "N/A") === range(3, 10))[/syntax]
Post Reply