Use array_unshift() to add one or more elements to the beginning of an array

Use array_unshift() to add one or more elements to the beginning of an array

array_unshift() allows you to insert one or more elements at the beginning of an array. It modifies the original array by shifting existing elements to higher indexes and adding the new elements. This can be helpful when you need to prepend elements to an array.

← Back to Tips List