看来前2个([1]
和['value']
)和最后2个([0]
和['key']
)元素总是相同的,那么重点是什么?< / p>
<?php
$foo = array("bob", "fred", "jussi", "jouni", "egon", "marliese");
$bar = each($foo);
print_r($bar);
?>
Array
(
[1] => bob
[value] => bob
[0] => 0
[key] => 0
)
答案 0 :(得分:1)
list
只能使用数字标记。这样就可以使用如下构造:
list($key, $val) = each($array);
等等:
$item = each($array);
echo $item['key']; // key is easier to understand here.