PHP list() 函数
PHP 教程
· 2019-01-22 20:29:30
实例
把数组中的值赋给一些变量:
<?php
$my_array = array("Dog","Cat","Horse");
list($a, $b, $c) = $my_array;
echo "I have several animals, a $a, a $b and a $c.";
?>
$my_array = array("Dog","Cat","Horse");
list($a, $b, $c) = $my_array;
echo "I have several animals, a $a, a $b and a $c.";
?>
定义和用法
list() 函数用于在一次操作中给一组变量赋值。
注释:该函数只用于数字索引的数组。
语法
list(var1,var2...)
| 参数 | 描述 |
|---|---|
| var1 | 必需。第一个需要赋值的变量。 |
| var2,... | 可选。更多需要赋值的变量。 |
技术细节
| 返回值: | 返回被赋值的数组。 |
|---|---|
| PHP 版本: | 4+ |
更多实例
实例 1
使用第一个和第三个变量:
<?php
$my_array = array("Dog","Cat","Horse");
list($a, , $c) = $my_array;
echo "Here I only use the $a and $c variables.";
?>
$my_array = array("Dog","Cat","Horse");
list($a, , $c) = $my_array;
echo "Here I only use the $a and $c variables.";
?>
点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html
Rapid Web Applications with TurboGears
Mark Ramm、Kevin Dangoor、Gigi Sayfan / Prentice Hall PTR / 2006-11-07 / USD 44.99
"Dear PHP, It's over between us. You can keep the kitchen sink, but I want my MVC. With TurboGears, I was able to shed the most heinous FileMaker Pro legacy 'solu-tion' imaginable. It has relationshi......一起来看看 《Rapid Web Applications with TurboGears》 这本书的介绍吧!