将2个php数组转换成一个2d javascript数组

I have this code:

$lat = $obj['geo']['coordinates'][0];
$long = $obj['geo']['coordinates'][1];

Its to do with google maps. So these two variables take the coordinate values (lat and long) from a mongodb. Assume this works.

And I have this in the javascript:

var loc = <?php echo json_encode($lat, $long); ?>;

I'm attempting here to make these two php arrays into a 2d javascript array, but it's not working.

Any help is greatly appreciated!

Try this:

var loc = <?php echo json_encode(array($lat, $long)); ?>;

If it's not that what you need, just tell it, i have some more ideas ;-)