开发者

Check multiple $_SESSION are empty

开发者 https://www.devze.com 2023-03-21 10:04 出处:网络
I have multiple $_SESSION variables with different names (e.g $_SESSION[\'blue\'], _SESSION[\'pu开发者_运维问答rple\'], _SESSION[\'cream\'] etc... is there any way I can use a loop to check which ones

I have multiple $_SESSION variables with different names (e.g $_SESSION['blue'], _SESSION['pu开发者_运维问答rple'], _SESSION['cream'] etc... is there any way I can use a loop to check which ones are empty and therefore ignore?


foreach ($_SESSION as $key => $value) { 
    if (empty($value)) {
         // ignore 
    }
}


You could use foreach loop

foreach ($_SESSION as $key => $value)
{
  // This goes through the keys that exist.
}
0

精彩评论

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