In-depth explanation of php list() function_PHP tutorial

WBOY
Release: 2016-07-21 15:09:18
Original
815 people have browsed it

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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!