tags:

views:

93

answers:

1

I'm working on a google maps project, where you add addresses to a database, and then click a "geocode these addresses" type of button. It will then take you to a page telling you how successful it was.

However, if google doesn't recognize an address, I want there to be a list of those addresses at the top, with textboxes to either specify your own coordinates, or to re-type the address, and then to try submitting it again. When that form submits (via post), I want to be able to grab an arbitrary number of fields, build a list out of their values, and then either re-send them to Google (if the addresses were changed), or add them with their custom-coordinates into the database.

So, how can I submit and process an arbitrary number of POST fields? Is there a way to use it like argc/argv in C (or similar languages)?

+6  A: 

PHP will create an array of values if the input tag name ends with []. For example, given the HTML:

  <input name="input_data[]" ... />
  <input name="input_data[]" ... />
  <input name="input_data[]" ... />

When the form is submit, the PHP variable $_POST['input_data'] is an array containing the three input values.

nathan
awesome, thank you
Carson Myers