so I have this code:
var loc = new Array();
<?php foreach($loc as $key => $val) { ?>
loc.push('<?php print_r($val); ?>');
<?php } ?>
The problem is is that it's only showing one value and not more than one, like it should. This is the php array code:
$loc = array($lat, $long);
Any help is greatly appreciated.
print_ris only for debugging. It's not for anything else.print_r()? It's only used to display a formatted version of your array and is not to be used for transferring data from client <-> server. Use JSON format instead, as shown in Niet's answer below.