What\'s the most elegant way in PHP to move an array element chosen by key to the first position?
Input:
$arr[0]=0; $arr[1]=1; $arr[2]=2; .... $arr[n
No need to unset keys. To keep it short just do as follow
//appending $new in our array array_unshift($arr, $new); //now make it unique. $final = array_unique($arr);
Demo