With the accepted proposal it creates an alternative to using “list” for destructuring an array. In all previous versions of PHP this works like this:
list($a, $b, $c) = array(1, 2, 3);
Now you can extract using a square bracket just as you do for assignment:
[$a, $b, $c] = [1, 2, 3];
[“a” => $a, “b” => $b] = [“a” => a, “b”, => 2];
Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer. You can expect quick tips, links to interesting tutorials, opinions and packages. Want to learn the cool stuff? Then sign up now!