Home > Backend Development > PHP Tutorial > Brief analysis of list() function usage examples in PHP_php skills

Brief analysis of list() function usage examples in PHP_php skills

WBOY
Release: 2016-05-16 20:00:41
Original
1346 people have browsed it

The example in this article describes the usage of the list() function in PHP. Share it with everyone for your reference, the details are as follows:

The list() function in PHP is used to assign values ​​to a set of variables in one operation.

Note: The array variable here can only be a numerically indexed array, and it is assumed that the numerical index starts from 0.

list() function definition is as follows:

list(var1,var2...)

Parameter Description:

var1 Required. The first variable to be assigned a value.
var2,... Optional. More variables need to be assigned values.

Sample code is as follows:

<&#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

I hope this article will be helpful to everyone in PHP programming.

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