我在我的会话中有一个产品阵列 产品是名称,代码和数量的阵营,我想在按qty_up按钮时更改数量: 我的PHP:如何更改会话数组变量值
if ($_POST['qty_up']==''){
foreach ($_SESSION["products"] as $key => $val)
{
if ($val["product_code"] == $_POST['code']) {
$val["product_qty"] += 1;
}
}
}
这改变$ VAL [ “product_qty”],但不是在会议
这是我的产品阵列中的会议的真正价值:
array (size=1)
'products' =>
array (size=5)
213453 =>
array (size=5)
'product_qty' => string '1' (length=1)
'product_code' => string '213453' (length=6)
'product_name' => string 'Kingfisher' (length=10)
'product_price' => string '12.00' (length=5)
48754 =>
array (size=5)
'product_qty' => string '1' (length=1)
'product_code' => string '48754' (length=5)
'product_name' => string 'Minute maid' (length=11)
'product_price' => string '2.00' (length=4)
'3545231ES0' =>
array (size=5)
'product_qty' => string '1' (length=1)
'product_code' => string '3545231ES0' (length=10)
'product_name' => string 'Jagurt' (length=6)
'product_price' => string '1.00' (length=4)
'$键=>&$ val'看到这个'&'? –
哇,这是魔术,你可以把它放在答案,所以我可以投票吗?这是为什么? –
请阅读说明书 - http://php.net/manual/en/control-structures.foreach.php –