Skip to content

Latest commit

 

History

History
15 lines (9 loc) · 454 Bytes

assign-many-variables-from-array.md

File metadata and controls

15 lines (9 loc) · 454 Bytes

Assign many variables from an array with list in PHP

Similar to object destructuring in JavaScript, assign variables from an array by using the list construct.

$simpsons = array('homer', 'marge', 'bart');

// Listing all the variables
list($homer, $marge, $bart) = $simpsons;
echo "$homer, $marge, and $bart are all characters\n";

See the official documentation for more details.