(HTML) Form element arrays

By | June 29, 2015

Sometimes you might want to group form elements in arrays.
Here’s a way to do that:

<form>
    <input type="text" name="textboxes[]">
    <input type="text" name="textboxes[]">
    <input type="text" name="textboxes[]">
</form>

The structure of the $_POST array will then be:

Array
(
    [textboxes] => Array
        (
            [0] => value 1
            [1] => value 2
            [2] => value 3
        )

)

Leave a Reply

Your email address will not be published. Required fields are marked *