I have the following data, when doing var_dump() on my data:
["time_zone"]=>
string(6) "London"
["geo_enabled"]=>
bool(false)
["verified"]=>
bool(true)
I can do the following to access the string "London": $UserTimeZone = $userProfile->time_zone;
However I also need to be able to determine whether the "verified" bool value is true/false.
How can I write an if to check if the "verified" bool value is true/false.
I’ve tried the following and it isn’t working it always returns – not verified:
$verified->verified;
if ($verified) {
echo "verified";
} else {
echo "not verified";
}
Any help appreciated.
It doesn’t look like you are actually setting the variable $verified, in which case it would always result as false in your if statement.
Or, you could do:
This way you don’t have to worry about setting any extra variables, you’re just accessing what is stored in the object.