<?php //遍历数组的2种方式 $arr=array( "1"=>"hello", "2"=>"my", "3"=>"lord" ); //方式1: function show1(){ while (list($key, $val) = each($arr)) { echo "$key 显 $val <br />"; } } //方式2: function show2(){ foreach ($arr as $k=>$v) { echo $k . ' 显 ' . $v ."<br>"; } }