PHP Array to json, how to get rid of some double quotes? -


i have small weird problem while encoding php arrays json.

i need prevent array() adding double quotes around specific values.

here php array:

$coordinates="[".$row["lat"].",".$row["lng"]."]";   $eguser=array(                            "geometry"=>array(                 "type"=>"$type",                 "coordinates"=>$coordinates                          ),              "type2"=>"$type2",             "id"=>$id         ); $arrayjson[]=$eguser;    

wich return following json json_encode :

var member = { "type": "featurecollection", "features": [{     "geometry": {         "type": "point",         "coordinates": "[46.004028,5.040131]"     },     "type2": "feature",     "id": "39740" }] 

};

as can see coordinates wrapped inside double quote >

"coordinates": "[46.004028,5.040131]" 

how rid of these quotes ? need have following instead >

"coordinates": [46.004028,5.040131] 

i'm bit confuse welcome :) thank !

thats because $coordinates of type string.

$coordinates="[".$row["lat"].",".$row["lng"]."]"; 

create $coordinates this

$coordinates = array($row["lat"],$row["lng"]); 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -