Assume I have a array like this:
$arr1 = ('red', 'blue');
and then I do:
list($color1, $color2, $color3) = $arr1;
I get 2 nice variables with the array values.
Is it possible to somehow set $color3 to have a default value in case it’s not present in the array, but with as little code as possible (without using if checks and stuff like that)?
I tried with list($color1 = 'default', $color2 = 'default', $color3 = 'default') = $arr1; but it doesn’t work…
$color1will be ‘red‘$color2will be ‘green‘$color3will be ‘cyan‘