我正在使用以下代码
$val= $module[$i]['subModule'];
$val1=$module[$i]['submoduleId'];
$valArr['name'] = explode(",", $val);
$valArr1['id']= explode(",", $val1);
$result=array_merge($valArr,$valArr1);
foreach($result as $name)
{
if(!empty($name))
{
echo "<input type='checkbox' name='type[]' value='".$name['id']."'>".$name['name']." ";
}
}
显示未定义的索引错误。
我打印$ result变量我得到了以下输出:
Array ( [name] => Array (
[0] => group
[1] => checkin
[2] => personalinfo
)
[id] => Array (
[0] => 3
[1] => 2
[2] => 1
)
)
答案 0 :(得分:4)
试用此代码:
foreach($result['name'] as $key => $name){
echo "<input type='checkbox' name='type[]' value='".$result['id'][$key]."'>".$name." ";
}