Home > php教程 > php手册 > body text

深入php list()函数的详解

WBOY
Release: 2016-06-13 11:51:20
Original
1274 people have browsed it

list()
( PHP 4中, PHP 5中)
list-指定变量,好象他们是一个数组
描述
void list ( mixed $varname [, mixed $... ] )
像阵列( ) ,这是不是一个真正的功能,而是一种语言结构。名单( )是用来指定名单中的变数之一作业。
参数
varname
一个变量。
返回值
没有价值的返回。
实例
例如# 1名单( )的例子

复制代码 代码如下:


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


另外参考:http://www.jb51.net/w3school/php/func_array_list.htm
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template