I have custom ternary operation where I get user gender from numbers:
Code:
$value = 0;
$gender = $value === 0 ? 'Male' : $value === 1 ? 'Female' : 'Other';
echo $gender;
In my think this code must return Male
but return Female
. Here is example.
Or my ternary operation incorrect for getting Male
result?
My ternary operation not equal with this code?
Code:
if($value === 0) $gender = 'Male';
elseif($value === 1) $gender = 'Female';
else $gender = 'Other';