Compact `switch` alternative

Some situations in PHP require a set of variables to have values depending on some condition. To achieve such variable-assignment, a switch statement is the traditional GOTO, but PHP’s array syntax combined with the list() language construct. 

For example, if $a==1, then $b=2; $c=2, else if $a==2, then $b=... etc. If the condition is the value of some variable, like $a here, a switch-statement would look like:

The number of lines required to express this grows explosively with the number of variables and conditions to set. Instead, use this more elegant way, based on list():

Which grows linearly in LoCs with the number of conditions. Other benefits are improved DRY-ness and the guarantee that all variables in list() are assigned. Note how the default case is implemented as well. 

A simple back of the envelope test with 5 variables and 10 conditions shows the following results. All code was properly indented and formatted. Note also how compressing the list-based approach results in a bigger compression which indicates more DRY-ness. For the sake of testing, a compacted switch-based form, without line-breaks or tabs after assignment is used too. 

characterslinesgzip %
switch-based7237130%
switch-based (compacted)6673132%
list-based3021158%

These tests were simply done by piping the code through the wc and gzip programs. The list-based approach looks as follows:

The switch-based compact version is as follows:

Check out the one-liner to pick random values from an array.