对不起我的问题标题我真的不知道如何强调我的问题,但这里是样本数组:
这是我的代码
foreach ($_POST['noofguest'] as $keyg => $valueg) {
echo $valueg. "<br />";
}
foreach($_POST['room_no'] as $key => $value){
foreach($value as $key2 => $value2){
echo $value2 . " has " . $valueg . "<br />";
}
}
,结果是:
1
2
56 has 1
57 has 1
但这不是我想要的结果,我想要的是
1
2
56 has 1
57 has 2
这可能吗?
答案 0 :(得分:1)
对于第二个循环,您希望接收room_no
的相同索引,但仅在noofguest
数组内。这就是你应该做的事情:
foreach($_POST['room_no'] as $key => $value)
foreach($value as $key2 => $value2)
echo $value2 . " has " . $_POST['noofguest'][$key2] . "<br />";