title: Loop through an array and return the values sorted by a grouping pattern
body: <p>I'm trying to loop through an array and return the values sorted by a pattern (groups of two). My abstract math skills are failing me. I'm stumped, I can't figure out the pattern. Here's what I have so far.</p>
  
  <pre><code>$ars = array(
      0 =&gt; "red",
      1 =&gt; "blue",
      2 =&gt; "green"
      3 =&gt; "yellow",
      4 =&gt; "purple"
      5 =&gt; "black",
      6 =&gt; "white",
      7 =&gt; "orange"
  );
  $group_1 = '';
  $group_2 = '';
  foreach ( $ars as $ar ) :
     if ($ar == 0 || $ar == 1 ) :
       $group_1 .= $ar;
    elseif ($ar == 2 || $ar == 3) :
      $group_2 .= $ar;
    elseif ($ar == 4 || $ar == 5) :
      $group_1 .= $ar
    elseif ($ar == 6 || $ar == 7) :
      $group_2 .= $ar;
    endif;
  endforeach;
  echo group_1; //result (red,blue,purple,black)
  echo group_2; //result (green,yellow,white,orange)
  </code></pre>
  
  <p>Having trouble creating an efficient foreach statement that will sort through a variable number of $ars and return them in this grouping. Any help would be appreciated.</p>