Home > php教程 > php手册 > php用一步操作给一组变量进行赋值

php用一步操作给一组变量进行赋值

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:42:52
Original
1260 people have browsed it

list() 用一步操作给一组变量进行赋值。 list() 仅能用于数字索引的数组并假定数字索引从 0 开始。

例如

$result = mssql_query("SELECT User, Sex, Age FROM _User",$conn);
list($user, $sex, $age) = mssql_fetch_row($result);
echo $user.
;
echo $sex.
;
echo $age;

也可以为数组赋值:

$hotcity = array(jinan, qingdao, zibo);
list($addr[0], $addr[1], $addr[2]) = $hotcity ;
var_dump($addr);
?>

输出:
array(3) { [2]=> string(4) "淄博" [1]=> string(7) "青岛" [0]=> string(5) "济南" }

 

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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template