PHP中list()函数用法实例简析_PHP

WBOY
Release: 2016-05-28 11:49:28
Original
987 people have browsed it

本文实例讲述了PHP中list()函数用法。分享给大家供大家参考,具体如下:

PHP中的list() 函数用于在一次操作中给一组变量赋值。

注意这里的数组变量只能为数字索引的数组,且假定数字索引从 0 开始

list()函数定义如下:

list(var1,var2...)

参数说明

var1      必需。第一个需要赋值的变量。
var2,...  可选。更多需要赋值的变量。

示例代码如下:

<&#63;php
 //$arr=array('name'=>'Tom','pwd'=>'123456'); //错误!索引必须为数字索引!
 //$arr=array('1'=>'Tom','2'=>'123456'); //错误!数字索引必须从0开始!
 $arr=array('Tom','123456');
 list($name,$pwd)=$arr;
 echo "Welcome ".$name." ! Remember your password:".$pwd;
&#63;>

Copy after login

希望本文所述对大家PHP程序设计有所帮助。

Related labels:
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