How to post multiple <input type=“checkbox” /> as array in PHP?

前端 未结 5 956
悲哀的现实
悲哀的现实 2020-12-04 01:15

So that in PHP I can deal with them as :

foreach($_POST[\'checkboxname\'] as $i => $value)
...
5条回答
  •  天命终不由人
    2020-12-04 02:13

    for those HTML form elements that can send multiple values to server (like checkboxes, or multiple select boxes), you should use an array like name for your HTML element name. like this:

    
    

    also it is recommended that you use an enctype of "multipart/form-data" for your form element.

    then in your PHP scripts you can access the multiple values data as an array, just like you wanted.

提交回复
热议问题