var useCounts = [];//先定义一个一维数组 <?php foreach($useCounts as $k => $v){?> var k = <?php echo $k ; ?>; useCounts[k] = [];//再将每一个一维数组定义为维数组(一定要定义,否则不能使用useCounts[k][k1]形式),该定义要放在第一层循环中<?php foreach($v as $k1 => $v1){?>//获取二维数组的键var k1 = <?php echo $k1 ;?>;useCounts[k][k1] = <?php echo $useCounts["$k"]["$k1"] ; ?>;<?php }}?>
console.log(useCounts);
浏览器执行结果: