Question: I'm doing some validation now in PHP, and I'm running allot of conditional statements, for example:

```

if ($this->email->isValid($email))
return false;
if ($this->username->isValid($username))
return false;

```

ect.. 

Is there a nice way to do this? Or do I just run ten If statements like the ones above?
I can't use `switch` obviously, but I'm looking for that type of solution.. 

P.S... I'm using Zend Framework for validation

Answer: 
You could OR them like this:

```
if(cond1||
   cond2||
   cond3||
   cond4)
{
  return false;
}

```
Do something like this:

```
$errlvl = 0;

if($errlvl == 0 && $this->email->isValid($email)){
    $errlvl++;
}

if($errlvl == 0 && $this->username->isValid($username)){
    $errlvl++;
}

// your validation list keeps going

if($errlvl > 0){
    return false;
}

```

this will

1. Reduce redundancy because if there's an error in front, the following will not be checked.
2. you can keep adding on to the list
3. if you want to know how many errors occurred, you can remove $errlvl == 0 in the statements