I have a PHP array similar to this:
0 => \"red\", 1 => \"green\", 2 => \"blue\", 3 => \"yellow\"
I want to move yellow to index
You can do like this:
$array = array("red", "green", "blue", "yellow"); $last = array_pop($array); array_unshift($array, $last); print_r($array);
Result:
Array ( [0] => yellow [1] => red [2] => green [3] => blue )