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

WBOY
Release: 2016-07-13 17:44:23
Original
947 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...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!