How can I do a comparison when my array returns value with index.
Returned value is Array ( [isMember] => 0 ) and I want do to a comparison on the value only
if ($memberStatus == 0)
{
print_r($memberStatus);
}
How can I do a comparison when my array returns value with index.
Returned value is Array ( [isMember] => 0 ) and I want do to a comparison on the value only
if ($memberStatus == 0)
{
print_r($memberStatus);
}
If you have an array like this:
$data = [ 'isMember' => 0, 'data1' => 1, 'data2' => 2 /* ... */ ];
You can access single elements by using the name of the array and write the key in square brackets:
// change isMember to whatever key-value pair you need
$memberStatus = $data['isMember'];
if ($memberStatus === 0)
{
print 'user is a member';
}
else
{
print 'user it not a member';
}