mrbaseball34;10965154 wrote:but never in the switch cases...
Well technically that's not true - you certainly can use logical expressions (or any other expression) in the 'case' statements, e.g.:
switch(true) {
case 1 + 2 == 3:
echo "Hey - math still works!";
break;
default:
echo "... what happened to math?"
break;
}
is perfectly valid, as is:
switch(true) {
case $char == '0':
echo "Zero";
break;
// etc.
}
EDIT: I say it's "technically" true since it doesn't cause a parse error and does achieve the desired result despite it not being a very "good" (or "common", or "accepted", or ... etc.) way of (ab)using the switch() structure.