Answers for "array_unshift"

4

php add element to array first position

<?php
$queue = array("orange", "banana");
array_unshift($queue, "apple", "raspberry");
print_r($queue);
?>
  Array
(
    [0] => apple
    [1] => raspberry
    [2] => orange
    [3] => banana
)
Posted by: Guest on August-13-2020
0

array_unshift

$cola = array("naranja", "banana");
array_unshift($cola, "manzana", "frambuesa");
print_r($cola);

Array
(
    [0] => manzana
    [1] => frambuesa
    [2] => naranja
    [3] => banana
)
Posted by: Guest on June-11-2021

Browse Popular Code Answers by Language