title: PHP Modify Array
body: <p>I have the following array:</p>
  
  <pre><code>array(a, a, a, b, b, c, c, c, c, d, d);
  </code></pre>
  
  <p>When I loop through it and echo it, the result is:</p>
  
  <pre><code>a
  a
  a
  b
  b
  c
  c
  c
  c
  d
  d
  </code></pre>
  
  <p>How ever I want to echo it in such a way that it displays:</p>
  
  <pre><code>a
  b
  c
  d
  a
  b
  c
  d
  a
  c
  c
  </code></pre>
  
  <p>Here is the array in a grid to better explain what im trying to achieve</p>
  
  <pre><code>Current
  a a a b
  b c c c
  c d d
  
  What im tryin to do
  a b c d
  a b c d
  a c c
  </code></pre>
  
  <p>How would I do this?</p>
  
  <p><strong>Seeing some of your answers, its clear I didnt explain it well enough :/</strong></p>
  
  <p>i should have included what the array keys should look like:</p>
  
  <pre><code>0a 1a 2a 3b
  4b 5c 6c 7c
  8c 9d 10d
  
  0a 3b 6c 9d
  1a 4b 7c 10d
  2a 5c 8c
  </code></pre>
  
  <p>Heres how i need the arrays to be organised, by key</p>
  
  <pre><code>0a 
  1a 
  2a 
  3b
  4b 
  5c 
  6c 
  7c
  8c 
  9d 
  10d
  
  0a 
  3b 
  6c 
  9d
  1a 
  4b 
  7c 
  10d
  2a 
  5c 
  8c
  </code></pre>