Home >php教程 >php手册 >php数组和js数组遍历

php数组和js数组遍历

WBOY
WBOYOriginal
2016-06-06 19:58:581267browse

js for(key in arr){ console.log(arr[ key ] = arr[key]); } php $arr = array(k1:v1,k2:2); for($arr as $k=$v){ echo $k . = . $v . br/; }

js

    for(key in arr){
        console.log("arr[" + key + "] = " + arr[key]);
    }

php

    $arr = array("k1":"v1","k2":2);
    for($arr as $k=>$v){
        echo $k . " = " . $v . "
";
    }



Statement:
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