Sign in
Log inSign up

Post hidden from Hashnode

Posts can be hidden from Hashnode network for various reasons. Contact the moderators for more details.

Help pass multilevel php array to Javascript

Job Nyamolo's photo
Job Nyamolo
·Apr 5, 2018

Hi people

I need your help with this code. I'm stuck. This sample file developers.google.com/maps/documentation/j…

has a Javascript locations array var locations = [...];

I have tried the following code to replace the Javascript array in vain with PHP.

What am I doing wrong?

$strmarkers[0] = array("lat: -1.275292" => 'lng: 36.812072'); $strmarkers[1] = array("lat: -1.282243" => 'lng: 36.815677'); $strmarkers[2] = array("lat: -1.273801" => 'lng: 36.825859');

...

var mynewlocations = [ <?php echo json_encode($strmarkers); ?> ]