Destructuring arrays using list

suggest change

Use list() to quick assign a list of variable values into an array. See also compact()

// Assigns to $a, $b and $c the values of their respective array elements in           $array with keys numbered from zero
list($a, $b, $c) = $array;

With PHP 7.1 (currently in beta) you will be able to use short list syntax:

// Assigns to $a, $b and $c the values of their respective array elements in $array with keys numbered from zero
[$a, $b, $c] = $array;
// Assigns to $a, $b and $c the values of the array elements in $array with the keys "a", "b" and "c", respectively
["a" => $a, "b" => $b, "c" => $c] = $array;

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents