Home > Backend Development > PHP Tutorial > each() 回到4个值, list 赋值哪两个

each() 回到4个值, list 赋值哪两个

WBOY
Release: 2016-06-13 12:41:27
Original
793 people have browsed it

each() 返回4个值, list 赋值哪两个
初学php,请问each() 返回4个值, list 赋值哪两个
$prices = array('Tires' => 100, 'oil' => 10, 'Spark Plugs' => 4);
$item = each($prices);
print_r($item);
echo "
";
reset($prices);
while(list($a, $b) = each($prices)) {
echo "a:$a,b:$b 
";
}
?>
each($prices)的值是4个key value 的数组,
Array ( [1] => 100 [value] => 100 [0] => Tires [key] => Tires ) 

而list($a, $b) = each($prices)) 为什么会把$item[key],$item[value]赋值给$a, $b,而不是$item[1],$item[value]。
list不应该是顺序赋值么。
网上找了,官方文档文档也找了,都没有准确答案,各位同学求解额

each list
Related labels:
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