Possible Duplicate:
How to check if an array value exists
I have a problem in PHP. So, my problem is that I want to see if a particular value exists in a session (in which session I store an array). And if this value exists to return me a boolean ($check=TRUE). But when I try to stop the script with die (var_dump($check)); in order to check the value, I get always this notice:
Undefined variable check…
This is my code:
$individualitem[] = $_SESSION["books"] ;
foreach ($individualitem as $key => $idividualvalue){
if($individualitem == $card){
$check = TRUE;
}
}
// die (var_dump($check));
Probably because the if condition is always false. Defined your $check before the actual foreach loop
But for your purpose, try