list()
and the
ArrayAccess
Interface
PHP 7 adds support for using the list()
statement
with classes that implement the ArrayAccess
interface:
$obj = new ArrayObject(['a', 'b']);
list($a, $b) = $obj;
var_dump($a, $b);
Executing the above example will result in the following output when PHP 7 is used:
string(1) "a"
string(1) "b"
In previous versions of PHP both $a
and
$b
were null
.