note 102469 added to reserved.variables.post

From: Date: Wed, 16 Feb 2011 17:16:43 +0000
Subject: note 102469 added to reserved.variables.post
Groups: php.notes 
Request: Send a blank email to php-notes+get-177041@lists.php.net to get a copy of this message
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) ---- Server IP: 69.147.83.197 Probable Submitter: 137.99.80.33 ---- Manual Page -- http://www.php.net/manual/en/reserved.variables.post.php Edit -- https://master.php.net/note/edit/102469 Del: integrated -- https://master.php.net/note/delete/102469/integrated Del: useless -- https://master.php.net/note/delete/102469/useless Del: bad code -- https://master.php.net/note/delete/102469/bad+code Del: spam -- https://master.php.net/note/delete/102469/spam Del: non-english -- https://master.php.net/note/delete/102469/non-english Del: in docs -- https://master.php.net/note/delete/102469/in+docs Del: other reasons-- https://master.php.net/note/delete/102469 Reject -- https://master.php.net/note/reject/102469 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#177041) next »