Reputation: 497
I'm trying to generate all different combinations for something that have x>=y, x<=y
ex: $abc <= 123 && $abc >= 123 && $abb >= 123 && $abb <= 123 && $acc >= 123
however, I don't want things such as "$abc <= 123 && $abc >= 123" to be saved (I'd want the combination: $abc <= 123 && $abb >= 123 && $acc >= 123 to be saved, no conflicting arguments), so I'm trying to use an if statement to filter them out, sometimes there are multiple conflicting arguments such as "$abc <= 123 && $abc >= 123 && $abb >= 123 && $abb <= 123" but I'm having trouble
$string = '$abc <= 123 && $abc >= 123 && $abb >= 123 && $abb <= 123 && $acc >= 123';
if(substr_count($string, "abc <=") == 0 && substr_count($string, "abc >=") == 1 || substr_count($string, "abc <=") == 1 && substr_count($string, "abc >=") == 0) {
echo("hello");
}
In this statement it won't return hello, which is right, but once you remove one conflicting argument from $string it will return hello, but I don't want this because still another conflicting argument exists. Is it possible to do something like this or I must do something like:
substr_count($string, "abc <=") == 0 && substr_count($string, "abc >=") == 1 && substr_count($string, "abb <=") == 1 && substr_count($string, "abb >=") == 0
Please advise
Sorry if this is a poorly asked question, it's hard to explain
Upvotes: 0
Views: 159