If you are interested in changing the sort order your elements in an array, you might want to read on this short tutorial on how you can shuffle your array and place a certain element string in a PHP array as the last key.

For example, lets say I have an array that looks like this:

$MyArray = ('monkey','lion','bear');

I want to move the 'lion' as the last element?

You can use this simple function:

function ShuffleArray($MyArray, $fromIndex, $toIndex) { 
    $targetElement = $MyArray[$fromIndex];
    $shuffleInc = ($toIndex - $fromIndex) / abs ($toIndex - $fromIndex);
    for ($e = $fromIndex; $e != $toIndex; $e += $shuffleInc){
        $MyArray[$e] = $MyArray[$e + $shuffleInc];
    }
    $MyArray[$toIndex] = $targetElement;
    return $MyArray;
}

Usage:

$MyArray = ShuffleArray($MyArray,1,2);

Now $MyArray will have the following values:

[0] => 'bear',
[1] => 'monkey',
[2] => 'lion'