title: Working on genetics calculator, not getting the results I expect from my arrays
body: <p>I am working on a genetics calculator which sort of works, however not as I intend it to haha.</p>
  
  <p>I am using the following code:</p>
  
  <pre><code>&lt;?php
  
  function getGeneArray($geneString) {
      // check the argument for fitting your needs!
      if ( strlen($geneString) % 2 == 1 ) {
           die('Supplied geneString is not made of pairs!'); // better not die - handle errors according to your application methodology
      }
      // add additional error-catching (there are only certain possible base-pairs, if something else is found you should reject the string
  
      $genes = array();
      $i = 0;
      while ( $i &lt; strlen($geneString) )
      {
          $genes[] = substr($geneString, $i, 2);
          $i += 2; // Here is your mistake, you just $i++
      }
      return $genes;
  }
  
  function combinePairs($A, $B) {
      // uppercase genes build the string first, which means B must be uppercase to come first and A cant be uppercase -- no longer important
      if ($A !== $A &amp;&amp; $B === $B) {
          return $B.$A;
      } 
      return $A.$B;
  }   
  
  $gene1 = 'bbEe';
  $gene2 = 'bbEe';
  
  $geneA = getGeneArray($gene1);
  $geneB = getGeneArray($gene2);
  
  $possibilities = array();
  foreach ($geneA as $A) {
      foreach ($geneB as $B) {
          $possibilities[] = combinePairs($A, $B);
      }
  }
  </code></pre>
  
  <p>The output from running the above code is:</p>
  
  <p><code>Array ( [0] =&gt; bbbb [1] =&gt; bbEe [2] =&gt; Eebb [3] =&gt; EeEe )</code></p>
  
  <p>When in reality I would like it to be something like:</p>
  
  <p><code>Array ( [0] =&gt; bbee [1] =&gt; bbEe [2] =&gt; bbEE )</code></p>
  
  <p>What can I do/change to get the right sort of outcome?</p>