Home >Backend Development >PHP Tutorial >A brief analysis of examples of list function usage in PHP

A brief analysis of examples of list function usage in PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 09:07:04957browse

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. The

list() function is defined 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.

The 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;
?>

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

The above has introduced a brief analysis of the usage examples of the list function in PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

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
Previous article:php and mysql connectionNext article:php and mysql connection