note 102469 deleted from reserved.variables.post by danbrown
| From: | danbrown@php.net | Date: | Wed, 16 Feb 2011 17:32:48 +0000 |
| Subject: | note 102469 deleted from reserved.variables.post by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177045@lists.php.net to get a copy of this message | ||
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)