I have this array and I need to use it in JS for google maps:
$punti = array(
array(
"location" => "new google.maps.LatLng(37.959571, -98.596719)",
"stopover" => "true"
),
array(
"location" => "new google.maps.LatLng(37.502230, -97.509929)",
"stopover" => "true"
)
);
Google maps need something like this:
[
{location: new google.maps.LatLng(37.959571, -98.596719), stopover: true},
{location: new google.maps.LatLng(37.502230, -97.509929), stopover: true}
]
The problem is that using the json_encode I have an array with double quotes and maps don't accept it.
With json_encode I have this result:
[{"location":"new google.maps.LatLng(37.959571, -98.596719)","stopover":"true"},{"location":"new google.maps.LatLng(37.502230, -97.509929)","stopover":"true"}];
How can I remove the double quotes? I tried str_replace and trim but doesn't work.
Thanks!
If Google wants it in that particular format, simply feed him :)
I supposed the json_encoded result stored in $json.
So, you can do this:
$json = str_replace('"','', (string) $json);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With