Hi Robert That is impossible to implement because there's no way to tell the parser that `switch` is statement or expression and it conflicts with `=>` in array key expression (that's why PHP chose to have arrow function with `fn` prefixed). And IMO your idea is harder to read than normal assignment
Regards On Wed, Oct 16, 2019 at 8:58 PM Robert Hickman <robehick...@gmail.com> wrote: > > > <?php > > > $say = switch (date("w")) { > > > case 0 => "weekend!"; > > > case 1, 2, 3, 4, 5 => "weekday :("; > > > case 6 => "weekend!"; > > > }; > > > echo "Today is {$say}"; > > If you had a really long expression, it may be easier to read if the > assignment was moved to the end, perhaps like this: > > switch (date("w")) { > case 0 => "weekend!"; > case 1, 2, 3, 4, 5 => "weekday :("; > case 6 => "weekend!"; > // lots more cases ... > } => $say; > > echo "Today is {$say}"; >