Skip to content

Instantly share code, notes, and snippets.

@southern-hu
Created April 20, 2013 00:01
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save southern-hu/5424068 to your computer and use it in GitHub Desktop.
Save southern-hu/5424068 to your computer and use it in GitHub Desktop.
HTML Multi checkbox set – the correct way to group checkboxes http://www.wastedpotential.com/html-multi-checkbox-set-the-correct-way-to-group-checkboxes/
<input type="checkbox" name="chk_group[]" value="value1" />Value 1<br />
<input type="checkbox" name="chk_group[]" value="value2" />Value 2<br />
<input type="checkbox" name="chk_group[]" value="value3" />Value 3<br />
<?php
if (isset($_POST['chk_group'])) {
$optionArray = $_POST['chk_group'];
for ($i=0; $i<count($optionArray); $i++) {
echo $optionArray[$i]."<br />";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment