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

前端 未结 5 974
悲哀的现实
悲哀的现实 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 01:58

    If you use an array for the checkboxes, you should add a value option as identifier for the single checkboxes, because then the returned array changes from Array ( [0] => on, [1] => on) to Array ( [0] => value1, [1] => value5 ), which let you identify the checked checkboxes.

提交回复
热议问题