# `array_push()` and `array_unshift()`

> Section in “New and Extended Functionality › Arrays” of the book [PHP 7 Explained](https://php7explained.com/) by Sebastian Bergmann and Stefan Priebsch, published by thePHP.cc. The book covers PHP 7.0 to 7.4 and was last updated in November 2020. HTML version: <https://php7explained.com/new-and-extended-functionality/arrays/array_push-and-array_unshift/>

`array_push()` and `array_unshift()` can now also be called with a single argument:

``` php
$array = [];

array_push($array);
array_unshift($array);

var_dump($array);
```

Executing the code shown above will print the output shown below:

    array(0) {
    }

Being able to call `array_push()` and `array_unshift()` with only a single argument is useful when the spread operator `...` is used as `...$values` may be unpacked to an empty list in which case `array_push($array, ...$values)`, for instance, leads to `array_push()` being called with only `$array` as argument.

---

Previous: [array_merge() and array_merge_recursive()](https://php7explained.com/new-and-extended-functionality/arrays/array_merge-and-array_merge_recursive/index.html.md) | Next: [array_key_first() and array_key_last()](https://php7explained.com/new-and-extended-functionality/arrays/array_key_first-and-array_key_last/index.html.md)
