Home >Backend Development >PHP Tutorial >Detailed explanation of while(list($key,$val)=each($result)) in php to obtain array_PHP tutorial

Detailed explanation of while(list($key,$val)=each($result)) in php to obtain array_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:50:061154browse

In php, while(list($key,$val)=each($result)) reads the $result array value and loops to obtain the array content and assigns it to $key, $val.

Example

echo "

";

The code is as follows
 代码如下 复制代码


echo "类CAR中的所有方法名为:";

echo "

";

$result=get_class_methods("CAR"); //获取类CAR中的方法名get_class_methods()

while(list($key,$val)=each($result))   //循环获取数组内容

{

  echo "方法$key=>$val";

  echo "

";

}

Copy code


echo "All methods in class CAR are named:";

$result=get_class_methods("CAR"); //Get the method name in class CAR get_class_methods()

while(list($key,$val)=each($result)) //Loop to obtain the contents of the array

echo "Method $key=>$val"; echo "

"; } The list() function assigns values ​​to a set of variables using elements in the array.

Note that, similar to array(), list() is actually a language construct, not a function
http://www.bkjia.com/PHPjc/632647.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632647.htmlTechArticleIn php while(list($key,$val)=each($result)) is read $result array value and loop to obtain the array content and assign it to $key and $val. Example code is as follows Copy the code echo All methods in class CAR...
Statement:
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