Is tertiary operator possible here?
- by silow
I'm trying to set $value1, $value2, $value3 entirely using tertiary operators. This is what it looks like without tertiary
if ($chk1 == 20) {
$value1 = true;
if ($chk2 == 40) {
$value2 = 100 ;
$value3 = 300;
} else {
$value2 = 200 ;
$value3 = 400;
}
} else {
$value1 = false;
}
I can set $value2 and $value3, but not sure how to set $value1. Can it be done?
if ($chk1 == 20) {
$value1 = true;
$value2 = ($chk2 == 40) ? 100 : 200;
$value3 = ($chk2 == 40) ? 300 : 400;
} else {
$value1 = false;
}