← All docs

array_unshift()

Prepends one or more elements to the beginning of an array.

array_unshift()

function array_unshift(array $array, ...$values): int

Prepends one or more elements to the beginning of an array.

Parameters:

  • $array (array), passed by reference
  • ...$values — variadic: collects excess arguments into $values.

Returns: int

No examples yet — check examples/ and showcases/ for usage patterns.

Internals

For how array_unshift is implemented in the compiler, see the internals page.