当用户按下按钮时,我试图从多维数组中取消设置值。该数组如下所示:
array(1) {
[1726]=>
array(2) {
[1736]=>
int(1)
[1737]=>
int(4)
}
[2314] =>
array(2) {
[1436]=>
int(3)
[1567]=>
int(4)
[2457]=>
int(7)
}
}
我试图取消设置
$_SESSION['cart'][1][1]
到目前为止我做了什么:
switch ($action) {
case 'add':
$_SESSION['cart'][$deb_id][$product_id]++;
var_dump($_SESSION['cart']); exit();
break;
case "remove":
$_SESSION['cart'][$deb_id][$product_id]--;
if($_SESSION['cart'][$deb_id][$product_id] == 0) unset($_SESSION['cart'][$deb_id][$product_id]);
break;
case 'delete':
unset($_SESSION['cart'][$deb_id][$product_id]);
break;
}
答案 0 :(得分:0)
怎么样
$_SESSION['cart'][$deb_id][$product_id] = '';
unset($_SESSION['cart'][$deb_id][$product_id]);