我有一个设置复选框,如下所示
<div class="control-group">
<label class="control-label" for="environment">Environment</label>
<div class="controls">
<label class="checkbox inline" for="environment-0">
<input type="checkbox" name="environment['com1']" id="environment-0" value="1">
Com1
</label>
<label class="checkbox inline" for="environment-1">
<input type="checkbox" name="environment['com2']" id="environment-1" value="1">
Com2
</label>
<label class="checkbox inline" for="environment-2">
<input type="checkbox" name="environment['com3']" id="environment-2" value="1">
Com3
</label>
</div>
</div>
当我返回$_POST
数据时,我得到以下信息
array(7) {
["environment"]=>
array(2) {
["'com1'"]=>
string(1) "1"
["'com2'"]=>
string(1) "1"
}
我对处理数组有些陌生,并且很困惑如何引用com1
. 我正在尝试$envCom1 = $_POST["environment['com1']"];
但收到错误Undefined index: environment['com1']