PHP 4, PHP 5, PHP 7, PHP 8
list - Assign variables as if they were an array
Code Examples

list( mixed$var, [ ... mixed$vars] ): array

Like array, this is not really a function, but a language construct. list is used to assign a list of variables in one operation. Strings can not be unpacked and list expressions can not be completely empty.


Before PHP 7.1.0, list only worked on numerical arrays and assumes the numerical indices start at 0.



A variable.


Further variables.

Return Values

Returns the assigned array.


Version Description
7.3.0 Support for reference assignments in array destructuring was added.
7.1.0 It is now possible to specify keys in list. This enables destructuring of arrays with non-integer or non-sequential keys.

Related Functions

Example of list

Show all examples for list

PHP Version:

Function list:

Arrays Functions

Most used PHP functions