So that in PHP I can deal with them as :
foreach($_POST['checkboxname'] as $i => $value) ...
Add square brackets ( [] ) at the end of the checkbox name when a form has multiple checkboxes with the same name. PHP creates an associative array to stored values of the selected checkboxes if checkboxes have the same name that ends with [] .
To link several checkboxes together to make them into an array in the PHP $_POST array you need to make all of the checkboxes have the same name, and each name must end in "[]". When both of the checkboxes are filled and the form is submitted this produces the following array.
Do something like this:
<input type="checkbox" name="checkboxArray[]" />
Note the [] in the name.
Like this:
<input type="checkbox" name="checkboxname[]" /> <input type="checkbox" name="checkboxname[]" /> <input type="checkbox" name="checkboxname[]" /> <input type="checkbox" name="checkboxname[]" /> <input type="checkbox" name="checkboxname[]" />
Just append [] to their names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With