I am analyzing someone else’s PHP code and I’ve noticed that the input HTML has many hidden input fields with names that end with ‘[]’, for instance:
<input type="hidden" name="ORDER_VALUE[]" value="34" />
<input type="hidden" name="ORDER_VALUE[]" value="17" />
The PHP page that processes this input acquires each value like this:
foreach ($_REQUEST["ORDER_VALUE"] as $order_value) {
/...
}
What is the ‘[]’ used for? Specifying that there would be multiple input fields with the same name?
Yes. Basically PHP will know to stick all of those values with the same name into an array.
This applies to all input fields, by the way, not just hidden ones.