I am trying to output a JSON string using PHP and MySQL, but around latitude and longitude Output is to output as a string with quotes. This causes a problem when I'm trying to add markers to Google Maps.
This is my code:
$ sql = mysql_query ('Select where by markers! = "' '); $ Result = array (); ($ Line = mysql_fetch_array ($ sql)) {$ Result [] = Array ('Latitude' = & gt; $ row ['lat'], 'Longitude' = & gt; $ row ['lng'], 'Address '= & Gt; $ line [' address'], 'project_id' => $ line ['project_ID'], 'marker_id' => $ line ['marker_id']); } $ Json = json_encode ($ result); Echo "{\" marker \ ":"; Echo $ json; Echo "}"; Here is the expected output:
{"markers": [{"Latitude": 0.000000, "longitude": 0.000000, "address": " Here's the output I get: 2234 seconds Avenue, Seattle, WA "," Project_ID ":" 7 "," Marker_ID ":" 21 "}]} 2234 2nd Avenue, Seattle, WA "," Project_ID ":" [["Exchange": "0.000000", "Longitude": "0.000000", "Address": "7", "Marker_ID": "21"}]}
Note the quotation marks around the values of latitude and longitude.
You can also try
echo json_encode ($ result , JSON_NUMERIC_CHECK); Some references:
Comments
Post a Comment