When you are using checkboxes to submit multiple choices, there is no need to use the complex method further down the page where you assign a unique name to each checkbox.
Instead, just name each checkbox as the same array, e.g.:
<input type="checkbox" name="items[]" value="foo" />
<input type="checkbox" name="items[]" value="bar" />
<input type="checkbox" name="items[]" value="baz" />
This way your $_POST["items"] variable will return as an array containing all and only the checkboxes that were clicked on.
摘自:php手册