title: Passing form variables as arrays
body: <p>I'm building a multi-page form which I want to commit to the database at the very end of the process, so abandoned forms don't end up littering the data with incomplete junk records, so my initial thought to solve this problem would be to hold the already-submitted data in an array (almost in the same format as it would be had I SELECTed it out of the database), but I seem to be getting pretty confused and ending up with nested arrays and not getting the results I expect when debugging.</p>
  
  <p>So, for example, the first form looks something like this:</p>
  
  <pre><code>&lt;form action="step_2.php" method="post"&gt;
      &lt;input type="text" name="textfield1"&gt;
      &lt;input type="text" name="textfield2"&gt;
      &lt;input type="text" name="options[]"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>(The reason for the array field is since the user can programatically add additional fields, so whilst 'textfield1' &amp; 'textfield2' only has one value, 'options' should be submitted as an array).</p>
  
  <p>What I want to do it just grab the $_POST array and add it to the next field, something like this:</p>
  
  <pre><code>&lt;form action="step_3.php" method="post"&gt;
      &lt;input type="hidden" name="form1[]" value="&lt;?=$_POST?&gt;"&gt;
      &lt;input type="text" name="textfield3"&gt;
      &lt;input type="text" name="options2[]"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>But that doesn't seem to work. Ideally I'd like to end up on the last step of the form either with an array for each form, or a single array organised in a sensible way, e.g.;</p>
  
  <pre><code>[0] =&gt; Array
      (
          [textfield1] =&gt; Some Text
          [textfield2] =&gt; More Text
          [textfield3] =&gt; Yet More Text
          [options1] =&gt; Array
              (
                  [0] =&gt; Option A
                  [1] =&gt; Option B
              )
          [options2] =&gt; Array
              (
                  [0] =&gt; Option E
              )
      )
  </code></pre>
  
  <p>I'm assuming there's an easier way to do this, but currently my brain is turning to goo trying to wrap a synapse around it.</p>