Dive into the details of php list of functions

  • 2020-06-03 06:08:52
  • OfStack

list()
(PHP 4, PHP 5)
list- Specifies variables as if they were an array
describe
void list ( mixed $varname [, mixed $... ] )
Like array (), this is not a real function, but a language structure. List () is used to specify a variable in the list.
parameter
varname
1 variable.
The return value
No return of value.
The instance
For example, the # 1 list () example


<?php
$info = array('coffee', 'brown', 'caffeine');
// Listing all the variables
list($drink, $color, $power) = $info;
echo "$drink is $color and $power makes it special.n";
// Listing some of them
list($drink, , $power) = $info;
echo "$drink has $power.n";
// Or let's skip to only the third one
list( , , $power) = $info;
echo "I need $power!n";
// list() doesn't work with strings
list($bar) = "abcde";
var_dump($bar); // NULL
?>

Another reference: https: / / www ofstack. com w3school/php/func_array_list htm


Related articles: