0

ユーザーがボタンを押したときに、多次元配列から値を設定解除しようとしています。配列は次のようになります。

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;
}
4

1 に答える 1