is it correct to unset the session variable for a particular index as the vay whole session is made unset in PH开发者_如何学GoP?
I know this works: unset($_SESSION['bannersize'])
But does this works ? : unset($_SESSION['bannersize'][3])
or is there any other way to unset any particular desired index of the session and then again rearrange the values inside it to remove the empty index..?
If you want to remove an array item and reindex the array, you can use array_splice
to do so:
$input = array("red", "green", "blue", "yellow");
array_splice($input, 1, 1); // removes $input[1]
var_dump($input);
I know it is possible to unset a named key. ie you can unset arr['home']['manager']. But i am not very sure about arr['home'][1]. Probably that also should work.
精彩评论