title: php sort post data into arrays
body: <p>I would like to get some input values from post and store them in an array. Here are my input elements which are repeatable fields:</p>
  
  <pre><code>&lt;input type="text" class="form-control" id="exampleInputPassword1" name="itemquantity[]" /&gt;
  &lt;input type="text" class="form-control gettitles" id="exampleInputPassword1" name="buyproduct[]" /&gt;
  &lt;input type="text" class="form-control gettitles" id="exampleInputPassword1" name="freeproduct[]" /&gt;
  </code></pre>
  
  <p>When i submit the form and print_r i get the following (the fields have been repeated):</p>
  
  <pre><code>Array ( [itemquantity] =&gt; Array ( 
                                 [0] =&gt; 1 
                                 [1] =&gt; 4 
                                 ) 
          [buyproduct] =&gt; Array ( 
                                 [0] =&gt; 2 
                                 [1] =&gt; 5 
                                ) 
          [freeproduct] =&gt; Array ( 
                                  [0] =&gt; 3 
                                  [1] =&gt; 6 
                                 )
  </code></pre>
  
  <p>How can i group them by each repeated filed?</p>
  
  <p>So for example i would expect an output like this:</p>
  
  <pre><code>Array(
    Array [0](
      [itemquantity] =&gt; 1
      [buyquantity] =&gt; 2
      [freeproduct] =&gt; 3
    )
    Array [1](
      [itemquantity] =&gt; 4
      [buyquantity] =&gt; 5
      [freeproduct] =&gt; 6
    )
  )
  </code></pre>
  
  <p>Any help would be appreciated, thanks!</p>