php如何读取多选框数据

来源:互联网 发布:第二代民族政策 知乎 编辑:程序博客网 时间:2024/05/16 10:27
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 eachcheckbox.

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手册

原创粉丝点击