title: PHP password validator output
body: <p>I know there are several threads involving this subject already but my questions is more about the output. I have an array with 10 passwords. They are sent to a function to validate the password. Right now, the function is (somewhat) doing what I need it to, i.e. catching passwords that don't meet the criteria, but it is only catching one thing at a time. I need the function to return EACH criteria that the password did not meet. So for example: "abcd" should return a string stating that "Password is too short, Password did not contain a number, Password did not contain a special character, etc." </p>
  
  <p>How do I add to the string each time an if statement is not met? Thanks so much for any help!</p>
  
  <pre><code>function validatePassword($pwd) {
       if (strlen($pwd) &lt; '8') {
          $invalidPassword = "Your Password Must Contain At Least 8 Characters!";
      }
      elseif(strlen($pwd) &gt; '16') {
          $invalidPassword = "Your Password is too long!";
      }   
      elseif(!preg_match("#[0-9]+#",$pwd)) {
          $invalidPassword = "Your Password Must Contain At Least 1 Number!";
      }
      elseif(!preg_match("#[A-Z]+#",$pwd)) {
          $invalidPassword = "Your Password Must Contain At Least 1 Capital Letter!";
      }
      elseif(!preg_match("#[a-z]+#",$pwd)) {
          $invalidPassword = "Your Password Must Contain At Least 1 Lowercase Letter!";
      }
  
      return $invalidPassword;
  }
  
  $Passwords = array("donkeypass", "password", "Prebyt1na!", "1234", "abcd", "narW1@asndk", "pasS w0rd!", "maK%sh1ft", "mypasswordisthebestpasswordever!23493484023", "sD123#vAr2@y7");
  foreach ($Passwords as $value) {
      echo validatePassword($value);
  }
  </code></pre>