<?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 unshift() method adds a new element to an array (at the beginning), and "unshifts" older elements:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.unshift("Lemon");
//The unshift() method returns the new array length : >> 5
/*if you find this answer is useful ,
upvote ⇑⇑ , so the others can benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)*/
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.