I am having a hell of a time with this. I have a multidimensional array that I am storing in a session.
$d1 = array(1,2,3,4);
$d2 = array(1,2,3,4,5,6);
$d3 = array(1,2,3,4,5,6,7,8);
$d4 = array(1,2,3,4,5);
$_SESSION['array1'] = array($d1,$d2,$d3,$d4);
what I want to do is remove the $d2 array from the session array1
however when I do something like this
unset($_SESSION['array1'][1]);
you would think that $_SESSION['array1'] would then = array($d1,$d3,$d4);
however what that does is actually unset the whole session variable.
Then if I try something like
foreach ($_SESSION['array1'] as $k => $v) {
echo "The Key is $k: The Value is $v";
}
however that gives me an error
Invalid argument supplied for foreach()
The only conclusion that I can come to is that the session variable is being completely unset, not that just the specific key is being removed from the array.
is there any way that i can unset a specific value contained within an array that is part of a session variable?