Home > Backend Development > PHP Tutorial > PHP assigns values ​​to a set of variables in one step_PHP tutorial

PHP assigns values ​​to a set of variables in one step_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:44:23
Original
1029 people have browsed it

list() assigns values ​​to a set of variables in one step. list() can only be used with numerically indexed arrays and assumes that numerical indexing starts at 0.

For example

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

You can also assign values ​​to arrays:

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

Output:
array(3) { [2]=> string(4) "Zibo" [1]=> string(7) "Qingdao" [0]=> string(5) " Jinan" }

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478757.htmlTechArticlelist() Use one step to assign values ​​to a set of variables. list() can only be used with numerically indexed arrays and assumes that numerical indexing starts at 0. For example $result = mssql_query("SELECT User, Sex, Ag...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template