Given a construct like this:
<input type="checkbox" value="red" name="color[]" />
<input type="checkbox" value="green" name="color[]" />
<input type="checkbox" value="blue" name="color[]" />
if POST'ed to a PHP page the $_POST
super-global will add the values of the checked checkboxes to an array color
.
Is this a PHP-only convention or do other web-aware languages follow it also? If the latter, what other languages/libraries follow this convention?
I've seen it in ASP.NET MVC but it usually needs an index added, eg name="color[0]"
, name="color[1]"
, etc
Example here - Wits End with IDictionary<T,T> and ModelBinders, ASP.NET MVC 2.0