October 2005
Intermediate to advanced
372 pages
11h 35m
English
array_unshift()
int array_unshift ( array&arr, mixedvar[, mixed ...] )
The array_unshift() function takes an array and a new value as its only parameter, and pushes that value onto the start of the array, before all the other elements. This is the opposite of the array_shift() function.
$firstname = "Johnny";
$names = array("Timmy", "Bobby", "Sam", "Tammy", "Joe");
array_unshift($names, $firstname);
// first is Johnny, last is Joe