Answers for "put item in first index of array php"

PHP
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

php move index of a value to first position in array

//appending $new in our array 
array_unshift($arr, $new);
//now make it unique.
$final = array_unique($arr);
Posted by: Guest on May-20-2021

Code answers related to "put item in first index of array php"

Browse Popular Code Answers by Language