list() :
The list() function is used to assign values to a list of variables in one operation.
Note: This function only works on numerical arrays.
Syntax :
list(var1,var2...)
Example 1:
<?php
$animals = array("Dog","Cat","Horse");
list($a, $b, $c) = $animals;
echo "I have several animals, a $a, a $b and a $c.";
?>
Example 2: Using the second and third variables
<?php
$animals=
array("Dog","Cat","Horse");
list( ,$b , $c) = $animals;
echo "Here I only use the $b
and $c variables.";
?>
Comments
Post a Comment