欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

php数组和js数组遍历

程序员文章站 2022-03-21 22:01:26
...

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