Hades

PHP_ArrayList

Posted on 2016-02-02 19:57  Styxlord  阅读(232)  评论(0编辑  收藏  举报

 

<?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>";
    }

}
Death around us:run desperately!