【发布时间】:2016-07-12 07:45:10
【问题描述】:
我有这段代码可以从数据库中获取所有数据
while($row = mysqli_fetch_array($query)){
$therow1 = $row['r1'];
$therow2 = $row['r2'];
$therow3 = $row['r3'];//get
$therow4 = $row['r4'];//get
}
我怎样才能将$therow3 和$therow3 作为一个数组,然后将它作为数组传递给javascript。
javascript 数组中的预期输出为: $the_array
[
[-33.890542, 151.274856],
[-33.923036, 151.259052],
[-34.028249, 151.157507],
[-33.80010128657071, 151.28747820854187],
[-33.950198, 151.259302]
];
那我会在javascript中使用这个数组
<script type="text/javascript">
var locations = $the_array;
</script>
【问题讨论】:
-
$the_array[$therow3] = $row['r3'];
标签: javascript php arrays