I have an array of stdClass objects that are very simple, every object looks something like this:
object(stdClass)[408]
public 'propertyID' => string '2232' (length=4)
public 'price' => string '100000' (length=6)
public 'bedroomNumber' => string '2' (length=1)
Also I have a form with a few select fields like Min Price, Max Price and Min Bedroom Number, that it's supposed to filter the array items depending on what the users choose, the problem is that I don't know how to handle if the user selects multiple filters in an efficient way, for example if the user wants to get only the items with a max price of 10000 and 3 bedrooms.
I though about using if
statements for every condition but it's not efficient at all (I'd have to do something like if they're filtering by price only, bedroom number only, price and bedrooms, and every possible combination).
Is there an easy way to do this?
Thanks in advance!