-2
我从数据库中获取数据,但想要为它们添加2个键。所以我将它们添加到for循环中。如果我转储(打印带有pre标签的数组的简单函数)for循环中的单个结果,这是正确的,当我将二维数组转储到其外部时,它不再有密钥了。将键/值对推到一个数组中,丢失了forloop键
For有些原因,它不会推到2维数组?
$ results是一个2维数组btw。
//add amount and subtotal to the array's elements
foreach ($results as $result) {
$result['amount'] = $sessionShoppingCart[$result['artikelnummer']][1];
$result['subtotal'] = $result['amount'] * $result['Verkoopprijs'];
$this->dump($result);
}
$this->dump($results);
哦,上帝,我觉得愚蠢。不知道你不得不在php tho中引用数组。图形它与C#中的相同,谢谢! – Lonefish