Given an integer $value
in the range of 1, 2, 3
, I want to get an array that starts with $value
and proceeds with the remaining two integers from above in arbitrary order. The best I could think of was doing something like this:
switch ($value) { case '1': $array = [1,2,3]; break; case '2': $array = [2,1,3]; break; case '3': $array = [3,1,2]; break; }
Is there a shorter and more beautiful way of doing that? Something like that:
$array = push_to_top_of_array($value,[1,2,3]);