Check multiple $_SESSION are empty
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.
}
精彩评论