我有这段代码:
foreach (array_combine($_SESSION['prod'], $_SESSION['pid']) as $prod => $pid)
{
echo 'od_no: '.$prod.' - '.'prod_id: '.$pid.'<br>';
}
我还希望在foreach
循环中包含另一个会话的值$_SESSION['so']
。我怎么能这样做?
答案 0 :(得分:0)
如果所有数组具有相同的大小,并且相同索引处的元素是相关的:
foreach ($_SESSION['prod'] as $k => $prod) {
$pid = $_SESSION['pid'][$k];
$so = $_SESSION['so'][$k];
// rest of your code
}