title: Re-numbering text input array indices with jQuery
body: <p>I have the following block of HTML which is used to collect information about an item from the user as part of a form:</p>
  
  <pre><code>&lt;div class="clone_block"&gt;
    Name: &lt;input type="text" name="items[0][name]" /&gt;&lt;br /&gt;
    Amount: &lt;input type="text" name="items[0][amount]" /&gt;&lt;br /&gt;
    &lt;button class="delete"&gt;Delete&lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I can clone this element (if the user wants to add another item) and place it after the last instance of <code>div.clone_block</code> in the DOM and everything works fine, and I can also delete elements. However, I end up with multiple instances of text inputs with the same name, which means only the last one shows up in a POST request (the previous ones are overwritten). What I want to do is re-number all the items so that the first is <code>item[0]</code>, the second is <code>item[1]</code> etc.</p>
  
  <p>Is there a way to do this in jQuery? Creating the names in this way makes it easier to process the POST data with PHP, so I don't want to change the naming scheme if possible.</p>