list() Or array()
<?php
class X { public array $list = [2]; }
$list = new X ;
//list($a) = list($b) = $list->list;
//echo $a;
//echo $b;
[$a] = $c = [$b] = $list->list;
echo $a;
echo $b;
print_r( $c );
PHP 8.6 is deprecating the list() keyword, though not the features, which stays with the short syntax. So, the question now is: what happens when you chain list() and arrays?
To be a list, the [] as to be filled with variables, or any container, and on the left site of at least one assignation = operation. That way, it will be assigned the values from the rightmost array available. You can chain several list at the same time.
Any full assignation in the middle of them will do a full assignation too.
See Also
- List Or Array? [Try me]
PHP Features
Last updated: 09 November 2026