Home > Article > Backend Development > PHPlist, each function traverses arrays (source code attached)
The list function in PHP traverses the array?
How to use the list function: list(mixed$ variable 1[, mixed $variablen]), has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
1. How to use the list function list (mixed$ variable 1[, mixed $ variable n]), the code is as follows
<?php list($one,$two,$three)=array('张三','李四','王五'); //再次声明:单引号不解释变量,所以输出的是字符串$one// echo $one; echo '$two...'.$two.'<br/>'; echo '$three...'.$three.'<br/>'; ?>
It can be seen that the function of list is: the corresponding variable with subscript 0 in the cited array is 1, the corresponding variable with subscript 1 is 2, and so on.
Conclusion:
1: Assign Zhang San with subscript 0 to $one
2: Assign Li with subscript 1 Four is assigned to $two
3: Zhang San with subscript 2 is assigned to $three
. Finally, we get that the function of list is from left to right, --corresponding to the index array Subscript starting from 0;
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of PHPlist, each function traverses arrays (source code attached). For more information, please follow other related articles on the PHP Chinese website!