Question: I've got four variables, and if any two or more of them return true, I need to throw an error. I could technically do something like this:

`if (($var1 && $var 2) || ($var1 && $var3) || ($var1 && $var 4) ... || ($var4 && $var3))`, but that gets super complex and hard to manage. I imagine there's got to be a better way to do this.

Thanks.

Answer: 
Beste way is to use an array and loop through the array.

```
$my_vars = array($var1, $var2, $var3, ...);
$test_var = 'something';
$hits = 0;
foreach($my_vars as $var) {
    $hits = $var == $test_var ? $hits++: $hits;
    if($hits >= 2) {
        throw new Exception('This is bad dude...);
    }
}

```
How about this?

```
<?php
$count = 0;
foreach(array($var1, $var2, $var3, $var4) as $value) {
  $count += (int) (bool) $value;
  if($count >= 2) {
    throw new Exception('an error');
  }
}

```