I have a session that looks like this:
array(3) {
["counter"]=>
int(0)
["currentItem"]=>
string(1) "2"
["addedToCart"]=>
array(12) {
[0]=>
array(11) {
["aantal"]=>
int(1)
["id"]=>
string(1) "1"
["filmtitel"]=>
string(11) "a_bugs_life"
["film_id"]=>
string(1) "2"
["zaal_id"]=>
string(1) "1"
["zaaltitel"]=>
string(6) "zaal 1"
["tijdstip"]=>
string(8) "15:00:00"
["stoeltjes"]=>
string(2) "21"
["dag"]=>
string(8) "woensdag"
["verwijder"]=>
int(2)
["vertoningId"]=>
string(1) "3"
}
[1]=>
array(11) {
["aantal"]=>
int(1)
["id"]=>
string(1) "1"
["filmtitel"]=>
string(11) "a_bugs_life"
["film_id"]=>
string(1) "2"
["zaal_id"]=>
string(1) "1"
["zaaltitel"]=>
string(6) "zaal 1"
["tijdstip"]=>
string(8) "15:00:00"
["stoeltjes"]=>
string(1) "7"
["dag"]=>
string(8) "woensdag"
["verwijder"]=>
int(2)
["vertoningId"]=>
string(1) "3"
}
[2]=>
array(11) {
["aantal"]=>
int(1)
["id"]=>
string(1) "1"
["filmtitel"]=>
string(11) "a_bugs_life"
["film_id"]=>
string(1) "2"
["zaal_id"]=>
string(1) "1"
["zaaltitel"]=>
string(6) "zaal 1"
["tijdstip"]=>
string(8) "15:00:00"
["stoeltjes"]=>
string(2) "22"
["dag"]=>
string(8) "woensdag"
["verwijder"]=>
int(2)
["vertoningId"]=>
string(1) "3"
}
}
}
Now, from $_SESSION['addedToCart] I would like to remove arrays if they meet to certain conditions. I have tried the following.
foreach ($_SESSION["addedToCart"] as $arr) {
if ($arr["stoeltjes"] == $stoeltje && $arr['film_id'] == $id) {
unset($arr);
}
}
This doesn't seem to work, it doesn't remove anything, I did a var_dump to check if the variables $stoeltje and $id were fine and they were fine so that cant be the problem. Am I able to use unset in this kind of situation?