Hello,
Submitting multi-value form fields, i.e. submitting arrays through GET/POST vars, can be done several different ways, as a standard is not necessarily spelled out.
Three possible ways to send multi-value fields or arrays would be:
- ?cars[]=Saab&cars[]=Audi (Best way- PHP reads this into an array)
- ?cars=Saab&cars=Audi (Bad way- PHP will only register last value)
- ?cars=Saab,Audi (Haven't tried this)
Form Examples
On a form, multi-valued fields could take the form of a select box set to multiple:
<form>
<select multiple="multiple" name="cars[]">
<option>Volvo</option>
<option>Saab</option>
<option>Mercedes</option>
</select>
</form>
(NOTE: In this case, it would be important to name the select control some_name[], so that the resulting request vars would be registered as an array by PHP)
... or as multiple hidden fields with the same name:
<input type="hidden" name="cars[]" value="Volvo">
<input type="hidden" name="cars[]" value="Saab">
<input type="hidden" name="cars[]" value="Mercedes">