php add element to array first position 1

php add element to array first position

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

Here is what the above code is Doing:
1. First, we create an array called $queue with two elements: “orange” and “banana”.
2. Then, we use array_unshift() to add two elements to the beginning of the array: “apple” and “raspberry”.
3. Finally, we print the array to the screen using print_r().

Similar Posts