I have to convert an multi-dimensional array to a simple array which can be used by leafletjs

Viewed 26
1 Answers

Without being able to see any code you may have, I'd guess your array in php looks like

$myArray = array(array('x1', 'x2'), array('y1', 'y2'));

What you need to do is json_encode it and it will be accessible to your javascript:

<?php $myArray = json_encode($myArray); ?>
<script> var myArray = <?= $myArray ?>; </script>
Related