时间:2021-07-01 10:21:17 帮助过:9人阅读
方法1:foreach
$sports = array(
football => good,
swimming => very well,
running => not good);
foreach ($sports as $key => $value) {
echo $key.": ".$value."
";
?>
输出结果:
football: good
swimming: very well
running: not good
方法2:each
$sports = array(
football => good,
swimming => very well,
running => not good);
while ($elem = each($sports)) {
echo $elem[key].": ".$elem[value]."
";
?>
方法3:list & each
$sports = array(
football => good,
swimming => very well,
running => not good);
while (list($key, $value) = each($sports)) {
echo $key.": ".$value."
";
?>
http://www.bkjia.com/PHPjc/486188.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/486188.htmlTechArticle本文介绍PHP中遍历数组的 foreach、list、each 三个函数的使用方法: 方法1:foreach ?php $sports = array( football = good, swimming = very well, running = not...