# Short List Syntax

> 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/short-list-syntax/>

The `list()` statement allows us to assign variables as if they were an array:

``` php
$data = ['foo', 'bar', 'barbara'];

list($first, $second, $third) = $data;

var_dump($first);
var_dump($second);
var_dump($third);
```

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

    string(3) "foo"
    string(3) "bar"
    string(7) "barbara"

PHP 5.4 introduced the short array syntax, allowing the construction of arrays using the `[]` notation instead of using `array()`. The fact that `list()` still had to be used for unpacking array elements into variables was considered unesthetic by some.

The syntax shown below, which is supported as of PHP 7.1, is equivalent to the one shown above:

``` php
$data = ['foo', 'bar', 'barbara'];

[$first, $second, $third] = $data;
```

---

Previous: [Arrays](https://php7explained.com/new-and-extended-functionality/arrays/index.html.md) | Next: [list() and the ArrayAccess Interface](https://php7explained.com/new-and-extended-functionality/arrays/list-and-the-arrayaccess-interface/index.html.md)
