title: Flip (transpose) the rows and columns of a 2D array without changing the number of columns
body: <p>Normally, I'd be asking how to turn a 4-rowed, 3-columned array like this:</p>
  <pre><code>1      2        3
  4      5        6
  7      8        9
  10    11       12
  </code></pre>
  <p>Into a 3-rowed, 4-columned array like: (<strong>I DON'T WANT THIS</strong>)</p>
  <pre><code>1   4   7   10
  2   5   8   11
  3   6   9   12
  </code></pre>
  <p>But actually, I want to turn it into this:  (<strong>I WANT THIS</strong>)</p>
  <pre><code>1   5   9
  2   6   10
  3   7   11
  4   8   12
  </code></pre>
  <p>In other words, I want to flip the rows and columns, but keep the same &quot;width&quot; and &quot;height&quot; of the new array. I've been stuck on this for over an hour.</p>
  <p>This is the function I'm using to do a normal &quot;flip&quot; (the first example):</p>
  <pre><code>function flip($arr)
  {
      $out = array();
      foreach ($arr as $key =&gt; $subarr)
      {
          foreach ($subarr as $subkey =&gt; $subvalue)
          {
              $out[$subkey][$key] = $subvalue;
          }
      }
      return $out;
  }
  </code></pre>