3 回答
TA贡献1752条经验 获得超4个赞
请注意,数组是2 维而不是3 维,您访问的第 3 维将始终产生未定义,请查看下面的代码片段,其中获取值,并根据要求进行更改:
let MAarray = [["Max","Mustermann","N","A80"],["Michaela","May","N","A78"],["Hans","Gerstelhuber","N","M12"],["Alfred E.","Neumann","N","T25"],["James","Bond","N","M72"]];
console.log(MAarray[2][0]);
MAarray[2][0] = "New Name";
console.log(MAarray[2][0]);
TA贡献1802条经验 获得超4个赞
你在找这个……?
$MAtoJS = [];
$MAtoJS[] = array('Max','Mustermann','N','A80');
$MAtoJS[] = array('Michaela','May','N','A78');
$MAtoJS[] = array('Hans','Gerstelhuber','N','M12');
$MAtoJS[] = array('Alfred E.','Neumann','N','T25');
$MAtoJS[] = array('James','Bond','N','M72');
$MAarrayForJS = json_encode($MAtoJS);
?>
<script>
var MAarray = <?php echo $MAarrayForJS; ?>;
console.log(MAarray[0][0]); // Max
</script>
- 3 回答
- 0 关注
- 202 浏览
添加回答
举报