To add or insert a value into the front of a standard array using PHP is actually pretty simple thanks to the nifty little array_unshift function. (If you think about it, it does exactly the opposite of PHP’s array_shift function!)

In practice:

//declare an array to test on
$arr = array('apple','pear');
print_r($arr);

//right, now add 'peaches' to the front of the array
array_unshift($arr,'peaches');
print_r($arr);

//you can even push multiple items onto the front of the array
array_unshift($arr,'apricots','strawberries');
print_r($arr);

The array’s internal numeric index gets automatically renumbered in case you are wondering, meaning that $arr[0] will now point to the last item prepended to the array.

Nifty.