How to add elements to the beginning of an array in PHP – Programming Code Examples
PHP

How to add elements to the beginning of an array in PHP1 min read

Use the PHP array_unshift() function

You can use the PHP array_unshift() function to insert one or more elements or values to the beginning of an array.

Let’s check out an example to see how it works:




Output:

Leave a Comment