title: How to group posted array names by index in PHP
body: <p>I am currently working on a project where the fields scale when clicking on the "Add" button.<br>
  I am grouping each field like this: <code>name="packaging[]"</code>, <code>name="packaging[1]"</code>, <code>name="packaging[2]"</code> and so on. When I submit the form, this is how the data looks like when posted: </p>
  
  <pre><code>Array
  (
      [packaging] =&gt; Array
          (
              [0] =&gt; 1
              [1] =&gt; 2
          )
  
      [quantity] =&gt; Array
          (
              [0] =&gt; 1
              [1] =&gt; 2
          )
  
      [total-weight] =&gt; Array
          (
              [0] =&gt; 1
              [1] =&gt; 2
          )
  
      [length] =&gt; Array
          (
              [0] =&gt; 1
              [1] =&gt; 2
          )
  
  )
  </code></pre>
  
  <p>Using PHP I would like to convert the above code to look like this:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [packaging] =&gt; 1,
              [quantity] =&gt; 1,
              [total-weight] =&gt; 1,
              [length] =&gt; 1,
          )
      [1] =&gt; Array
          (
              [packaging] =&gt; 2,
              [quantity] =&gt; 2,
              [total-weight] =&gt; 2,
              [length] =&gt; 2,
          )
  )
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>