Home  >  Article  >  Backend Development  >  In-depth explanation of php list() function_PHP tutorial

In-depth explanation of php list() function_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:09:18816browse

list()
(PHP 4, PHP 5)
list - specifies variables as if they were an array
Description
void list ( mixed $varname [, mixed $... ] )
Like array(), this is not really a function, but a language construct . list() is used to specify one of the variables in the list job.
Parameters
varname
A variable.
Return Value
Return without value.
Example
Example #1 list( )

Copy code The code is as follows:

$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
?>

Also reference: http://www.jb51.net/w3school/php/func_array_list.htm

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327315.htmlTechArticlelist() (PHP 4, PHP 5) list-specifies variables as if they were an array description void list ( mixed $varname [, mixed $... ] ) like array( ) , which is not a real...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn