php list

To copy all of an array’s values into variables, use the list() construct

list ($variable, …) = $array;

The array’s values are copied into the listed variables in the array’s internal order. By default that’s the order in which they were inserted, but the sort functions described later let you change that. Here’s an example:

$person = array(“Fred”, 35, “Betty”);
list($name, $age, $wife) = $person;
// $name is “Fred”, $age is 35, $wife is “Betty”

Leave a Comment