title: How do I check if a String contains the same letter twice consecutively in php?
body: <p>I don't see why my code doesn't work, any suggestions?</p>
  
  <pre><code>$pattern_c_sap='/\.\-/';
  $local='.................';
  $local_array = explode( '', $local );
  
  for($i=0; $i&lt;=$local_length; $i++){
  if(preg_match($pattern_c_sap , $local_array[$i]) &amp;&amp; preg_match($pattern_c_sap , $local_array[$i+1])) {
      return false;
  }
  }
  </code></pre>
  
  <p>I had the following errors: 
  The regex should be</p>
  
  <pre><code>[/\.\-/]
  </code></pre>
  
  <p>and I should have used str_split instead of explode when splitting for each letter.</p>