From http://www.w3schools.com (Copyright Refsnes Data)
The list() function is used to assign values to a list of variables in one operation.
list(var1,var2...) |
Parameter | Description |
---|---|
var1 | Required. The first variable to assign a value to |
var2 | Optional. More variables to assign values to |
Note: This function only works on numerical arrays.
<?php $my_array = array("Dog","Cat","Horse"); list($a, $b, $c) = $my_array; echo "I have several animals, a $a, a $b and a $c."; ?> |
The output of the code above will be:
I have several animals, a Dog, a Cat and a Horse. |
<?php $my_array = array("Dog","Cat","Horse"); list($a, , $c) = $my_array; echo "Here I only use the $a and $c variables."; ?> |
The output of the code above will be:
Here I only use the Dog and Horse variables. |
From http://www.w3schools.com (Copyright Refsnes Data)