I have a php array of this type
[0] => Array ( [id] => 22 [lat] => 40.8434169 [lng] => 11.409390199999962 )
and I wish to pass it to a js file in body-onload.
I tried these ways:
1) <body onload="addMarkers(<?php print_r($myArray) ?>)">
2) <body onload="addMarkers(<?php echo json_encode($myArray) ?>)">
but without success
EDIT: I solved in this way
<script type="text/javascript">
var myJsArray = <?php echo json_encode($myArray) ?>;
</script>