note 102469 deleted from reserved.variables.post by danbrown
[email protected] Wed, 16 Feb 2011 09:32:48 -0800
| Newsgroups | php.notes |
|---|---|
| Message-ID | <[email protected]> |
Note Submitter: jon dot rifkin at uconn dot edu
----
PHP's processing of POSTs can read multiple input tags with the same name and turn them into an array, but you need to add "[]" to the name. For example, don't do this,
<input name="color" value="red">
<input name="color" value="blue">
<input name="color" value="green">
because only the last value will be kept, like this
$_POST["color"] = "green"
Instead, do this
<input name="color[]" value="red">
<input name="color[]" value="blue">
<input name="color[]" value="green">
This will give you an array of all the values,
$_POST["color"] = array("red","blue","green");
(Tested with PHP 5.3.3)