here i am trying to remove value from array, here i am passing action and id to page. i am checking if the values has been set and then perform action.
i want to remove value from array by value. here product_id is the value i am passing and the value has to be removed from array.
for ex:action=remove&product_id=22 the value 22 has to be removed from array
<?php
if(isset($_GET['action']) && isset($_GET['product_id'])){
if($_GET['action'] == "add"){
$product_id = $_GET['product_id'];
$_SESSION['cart'][] =$product_id;
}
if($_GET['action'] == "remove"){
unset($_SESSION['cart'][$product_id]);
echo "product_remove";
}
}
?>
how can i do this?
array_search()