I am creating A shooping cart using php i am updating my quantity on one update button correctly but when i delete a product that is set on an array index my index in not reindexing because i cant access my array
if(isset($_POST["addcart"])){
$a=productforcart($addcart);
$code=0;
// this $item that i want to access outside
$item = array(
$code=>array(
'pro_id'=>$_GET["id"],
'pro_name'=> $a["productname"],
'pro_details'=> $a["productdetails"],
'pro_price'=> $a["productprice"],
'pro_image'=> $a["productimage"],
'pro_quantity'=>1 )
);
if(empty($_SESSION["shooping_cart"])){
$_SESSION["shooping_cart"]=$item;
header("Location: product.php");
}
else{
$array_keys = array_column($_SESSION["shooping_cart"],"pro_id");
if(in_array($_GET["id"],$array_keys)) {
echo '<script>alert("Product Is Already Added To The Cart")</script>';
echo '<script>window.location="product.php"</script>';
} else {
$_SESSION["shooping_cart"] = array_merge($_SESSION["shooping_cart"],$item);
header("Location: product.php");
}
}
}