i have an array that looks like this:
Array (
[0] => Array (
[id] => 18
[name] => book
[description] =>
[quantity] => 0
[price] => 50
[status] => Brand New
)
[1] => Array (
[id] => 19
[name] => testing
[description] => for testing
[quantity] => 2
[price] => 182
[status] => Brand New
)
[2] => Array (
[id] => 1
[name] => Fruity Loops
[description] => dj mixer
[quantity] => 1
[price] => 200
[status] => Brand New
)
)
I want to be able to delete an entire row in the array (when a user clicks a delete link) say array[1]
which is:
[1] => Array (
[id] => 19
[name] => testing
[description] => for testing
[quantity] => 2
[price] => 182
[status] => Brand New
)
I have this code where i'm trying to delete based on the id of the product but it doesn't work
//$_SESSION['items'] is the array and $delid is the "product id" gotten when a user clicks delete on a particular row.
foreach ($_SESSION['Items'] as $key => $products) {
if ($products['id'] == $delid) {
unset($_SESSION['Items'][$key]);
}
}
How do i implement this? Thanks