Assuming there are 5 inputs in web form
If you change the name of your input to the_same[]
- $_REQUEST['the_same']
will become an array of those values, first to last in element order (all current browsers I believe).
You can also specify a specific order if you need, or even use string keys. For instance, an would become
$_REQUEST['the_same']['apple'][2]
Without using the []
on the input names, PHP will only see the last value. The other values will be 'overwritten' by the later value when the $_REQUEST
/$_GET
/$_POST
arrays are constructed.
An example of using that to your advantage could be with a checkbox, as the HTML checkbox only submits a value when checked, you may want to submit a "not checked" value somtime: