array_unshift

Syntax: int array_unshift ( array &$array , mixed $var [, mixed $… ] )
Description: Prepend one or more elements to the beginning of an array

<?php
$queue = array("orange", "banana");
array_unshift($queue, "apple", "raspberry");
print_r($queue);
?>

OUTPUT

Array
(
    [0] => apple
    [1] => raspberry
    [2] => orange
    [3] => banana
)

 

Leave a Reply

Your email address will not be published. Required fields are marked *