title: Checking for repeated letters in PHP
body: <p>I am creating a password validation tool, and one of the requirements I'd like is to prevent the user from having too many letters in a row.  Any letters, including capital letters, cannot be repeated in a sequence of 3 or more times.</p>
  
  <p>My approach has been to move through the password string with a for loop, and embedding a few checks using regex within that.  I can't seem to get the logic to work, and it's probably something simple.  Here is one of my (many) failed attempts at cracking this problem:</p>
  
  <pre><code>$seqLetterCounter = 0;
      for($i=0; $i &lt; strlen($password); ++$i) {
              if($password{$i} == '/([a-zA-Z])/') {
                  $seqLetterCounter++;
              }
              if($seqLetterCounter &gt; $this-&gt;maxSeqLetters){
                  $this-&gt;errors[6] = 'You have used too many sequential letters in your password.  The maximum allowed is ' . $this-&gt;maxSeqLetters . '.';
              }
              if($password{$i} == '/([^a-zA-Z])/') {
                  $seqLetterCounter = 0;
              }
          }
  </code></pre>
  
  <p>$password  - a posted value from a form.</p>
  
  <p>$maxSeqLetters - a protected variable that holds an integer value, defined by the user.</p>
  
  <p>errors[] - an array that is used to determine if the password has failed any of the various checks.</p>
  
  <p>Anyone have some pointers?</p>