For an example, let's say I have an array containing these six values (not necessarily in this order):
(1,5,9,2,4,7)
How can I check whether the value 1 AND value 2 AND value 3 exist at the same time within this array? In this case, the check would turn out false because the value 3 doesn't exist within the array, even though value 1 and value 2 do exist.
Right now, I'm doing this:
if (strpos($myarray, "1") !== false && strpos($myarray,"2") !== false && strpos($myarray,"3") !== false) {
echo "Values 1, 2, and 3 are present!";
}
This works so far, but it may not in the future if I have numbers larger than 9 (because then, checking for the value "1" will return true for 11, 12, 13, 14, 15, etc.). There has to be a better way, right?
In addition, I have to check not only for the existence of 1, 2, and 3 but for other combinations of values, as well, so it's going to look really messy if continue to use the above code to get it done.
Thanks!