I have a two dimensional array and wish to always delete/unset the last array item (in this case Array[3]) in the code sample below, before I put it into a SESSION.
I am still a novice with php and have tried the following with no success.
Any help would be greatly appreciated.
if (is_array$shoppingCartContents)) {
foreach($shoppingCartContents as $k=>$v) {
if($v[1] === 999999) {
unset($shoppingCartContents[$k]);
}
}
}
$shoppingCartContents = Array
(
[0] => Array
(
[productId] => 27
[productTitle] => Saffron, Dill & Mustard Mayonnaise
[price] => 6.50
[quantity] => 3
)
[1] => Array
(
[productId] => 28
[productTitle] => Wasabi Mayonnaise
[price] => 6.50
[quantity] => 3
)
[2] => Array
(
[productId] => 29
[productTitle] => Chilli Mayo
[price] => 6.50
[quantity] => 2
)
[3] => Array
(
[productId] => 999999
[productTitle] => Postage
[price] => 8.50
[quantity] => 1
)
)