I have an array that looks like this:Array ( [0] => Array ( [id] => 2 [name] => test product1 [description] => test [quantity] => 1 [price] => 188 [status] => Brand New [category] => Computer Software [subcategory] => Music Software [postdate] => 2013-05-19 [prodimage] => [user] => admin ) [1] => Array ( [id] => 2 [name] => test product1 [description] => test [quantity] => 1 [price] => 188 [status] => Brand New [category] => Computer Software [subcategory] => Music Software [postdate] => 2013-05-19 [prodimage] => [user] => admin )
I want to be able to delete an entire row e.g Array[0] which would mean deleting this;Array ( [0] => Array ( [id] => 2 [name] => test product1 [description] => test [quantity] => 1 [price] => 188 [status] => Brand New [category] => Computer Software [subcategory] => Music Software [postdate] => 2013-05-19 [prodimage] => [user] => admin )
.
I tried the following:
$delid = $_GET['delid']//the product id of the element on which DELETE link was clicked.
if($delid){
$contents = count($_SESSION['cartItems']);//$_SESSION['cartItems'] is the array shown above.
for($i=0; $i < $contents $i++){
foreach($_SESSION['cartItems'] as $products){
if($products['id'] == $delid){
unset($products[$i]);
}
}
}
}
But it doesn't delete the specified item form the array. Never implemented such a thing before so i'm a bit confused. How do i go about this? thanks