<?php
$queue = array("orange", "banana");
array_unshift($queue, "apple", "raspberry");
print_r($queue);
?>
$cola = array("naranja", "banana");
array_unshift($cola, "manzana", "frambuesa");
print_r($cola);
Array
(
[0] => manzana
[1] => frambuesa
[2] => naranja
[3] => banana
)
The array_unshift() function inserts new elements to an array. The new array values will be inserted in the beginning of the array.
Tip: You can add one value, or as many as you like.
Note: Numeric keys will start at 0 and increase by 1. String keys will remain the same.