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]=n;
$key=10;
Output:
$arr[0]=10;
$arr[1]=0;
$arr[2]=1;
$arr[3]=2;
....
$arr[n]=n;
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]=n;
$key=10;
Output:
$arr[0]=10;
$arr[1]=0;
$arr[2]=1;
$arr[3]=2;
....
$arr[n]=n;
After this simple code, all you need to do is display the re-arranged array. :)