Re: Q: How to get the value of a checkbox of which name without '[]'?

From: Date: Mon, 18 Aug 2003 20:42:38 +0000
Subject: Re: Q: How to get the value of a checkbox of which name without '[]'?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-159948@lists.php.net to get a copy of this message
----- Original Message ----- From: "Frode" <frode@lillerud.no> [...snip...] Which means I can't modify the code above into PHP prefered style: <input type=checkbox name="box[]" value=1> <input type=checkbox name="box[]" value=2> .... [...snip...] > Why is this the preferred style, and where can I read more about it? I don't know about preferred style or not, but if you want PHP to recognize multiple values from a form or URL, then you must add the [] onto the name so PHP will put it into an array. Otherwise you end up with "box=1&box=2&box=3" and when PHP parses that, each overwrites the other, so you end up with $box == 3 at the end and the other values are lost. I'm sure it's discussed in the Form Handling section of the manual. ---John Holmes...

« previous php.general (#159948) next »