I have a faint, faint memory that I have seen a solution for using ternary-like operators that works like a switch/case-statements in PHP. I may have seen it as an suggestion for future versions of PHP... I'm not sure, and I cannot find where I may have read it... or if my memory totally pranks me :)
The solution looked similar to this (the syntax is not correct though, I hope you understand anyway):
$weekday = $dayofweek ! 1 => "Monday", 2 => "Tuesday", ... , 7 => "Sunday" : "Unknown";
The alternative is to write...
switch ($dayofweek) {
case 1: $weekday = "Monday"; break;
case 2: $weekday = "Tuesday"; break;
...
case 7: $weekday = "Sunday"; break;
default: $weekday = "Unknown";
}
(I am aware of that I can use arrays in this simple example.)
Does this operator based version of switch/case really exist? Or... have I remembered wrong? :)