array_unshift
int array_unshift(array array, mixed var, mixed ...)
array | Array to modify |
var | Value to prepend to array |
... | Further values to prepend to array |
Pushes the list of elements onto the given array.
Returns:
Number of elements in the revised array; NULL on failure
Description:
Prepends the new elements onto array in the order given as arguments. The first element in the argument list becomes the first element in the array. Returns the number of elements in the revised array. This function changes the original array.
Combined with array_pop(), this function can be used to make an array act in FIFO (first-in-first-out) fashion.
Version:
PHP 4
See also:
array_pop() array_push() array_shift()
Example:
Push values onto the beginning ...
Get PHP Functions Essential Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.