开发者

is it correct to unset the session variable for a particular index as the vay whole session is made unset in PHP?

开发者 https://www.devze.com 2023-01-04 07:05 出处:网络
is it correct to unset the session variable for a particular index as the vay whole session is made unset in PH开发者_如何学GoP?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消