title: How to Submit empty array from HTML Form Post to PHP
body: <p>I just realized - I have no idea how to POST an empty array from an HTML form to PHP. I can POST arrays of size 1 or larger, but is there any way to post an empty array? I mean, like, you can have:</p>
  
  <pre><code>&lt;form&gt;
    &lt;input type='hidden' name='items[0]' value='Value Item 1' /&gt;
   &lt;input type='hidden' name='items[1]' value='Value Item 2' /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>which gives an array of size 2: <code>$_POST['items'] === ["Value Item 1", "Value Item 2"]</code> but is there any way to pass an empty array as the value of a $_POST key? That is, I know I can make <code>$POST['items'] === ''</code>, but an empty array (<code>[]</code>)?</p>
  
  <p>The specific use case is: I have a one to many form, say like a shopping cart with items. The form is populated by existing "items" from the DB, but can add or delete items, which are in an array of items. The array of items is indexed - if new items are added, they are saved to the DB; if items are deleted, they are removed from the array and deleted from the DB. </p>
  
  <p>All of which works fine - unless all the items are deleted from the form, in which case no "item" key is passed.</p>
  
  <p>I found the perfectly good work-around, which is to put a hidden input "items" = null at the top of the form, so the key is passed even if there are no items, then in PHP if the "items" key is '' I convert it to an empty array - so all works fine. I was just curious in theory if it was possible to POST an empty array. No idea why that is considered inappropriate - hope the explanation helps.</p>
  
  <p>As for why I want to check on the existence of the key - I use the same generic code to process inputs from different forms - so, if the user changes the address on the shopping cart without specifying the items, the items should not be deleted just because there is no "items" key.</p>
  
  <p>To clarify further, I'm not actually building a "Shopping Cart" - I'm building an abstract framework that supports mapping one-to-many POSTs to Eloquent One-To-Many relationships. Any field in a POST with an empty value is deleted from the Object - but any field/key NOT in the POST is NOT deleted or modified in the underlying DB. </p>
  
  <p>Point is, I'm building a generic tool-set - not just trying to get one function to handle one form.</p>