2011-07-19 52 views
0

我有不同名稱的多個$_SESSION變量(例如:$_SESSION['blue'], _SESSION['purple'], _SESSION['cream'] etc...有什麼辦法,我可以使用一個循環來檢查哪些是空的,因此忽略?

回答

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

Thanks @RohitChopra!:) – TronCraze

0

你可以使用foreach loop

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