want to minus the quantity when click delete if cart qty is more then 1

//remove item from shopping cart
if(isset($_GET["removep"]) && isset($_GET["return_url"]) && isset($_SESSION["products"])){
    $product_code   = $_GET["removep"]; //get the product code to remove
    $product_s      = $_GET["removes"]; //get the product size to remove
    $return_url     = base64_decode($_GET["return_url"]); //get return url

    foreach ($_SESSION["products"] as $key=>$cart_itm){ //loop through session array var
        if($cart_itm["id"] !=$product_code || $cart_itm["size"] !=$product_s){ //item does,t exist in the list
          $product[] =array(

        //create a new product list for cart
         $_SESSION["products"] = $product;
        //redirect back to original page

this code is deleting the product but i want minus also when qty is greater then 1

Why don't you just select the product merely by the product code? Or isn't that unique?


foreach($_SESSION['products'] as $key => $cart_item) {
    if($product_code == $_GET['product_code']) {
        //* This is the product of which we're reducing the quantity.

        // Substract one (or whatever you want) from the quantity.
        $cart_item['quantity'] -= 1;

        // Save the product in its session variable.
        $_SESSION['products'][$key] = $cart_item;

its not working in my code

You should not use that exact example, but modify it to your own needs. Or did you do that already and is it still not working?