PHP list array function
Last Updated: February 20, 2022
list – Assign values of the array to variables
Syntax
list(mixed $var, mixed ...$vars = ?): array
Supports (PHP 4 , PHP 5, PHP 7, PHP 8)
Parameters
Parameter | Description |
var | variable |
vars | more variables |
Return Value
Returns the assigned array.
Example
$info = array('coffee', 'brown', 'caffeine');
list($drink, $color, $power) = $info;
echo "$drink is $color and $power makes it special.\n";
Output
coffee is brown and caffeine makes it special.