如何在json中为叶子实时制作正确的数组

I am trying us to leaflet.js realtime. I have it working when I encode the coordinates like below. I have read the instructions and it does not specify how it wants the data but found this in a sample. How do I encode it to print it out as it should and is it possible to include more than one set of coordinates?

Any help would be great, thanks.

my php

$lat = "52.45238209999999";
$lng = "-1.743507099999988";

$str = "{".chr(34)."geometry".chr(34).": {".chr(34)."type".chr(34).": ".chr(34)."Point".chr(34).", ".chr(34)."coordinates".chr(34).": [".$lng.", ".$lat."]}, ".chr(34)."type".chr(34).": ".chr(34)."Feature".chr(34).", ".chr(34)."properties".chr(34).": {}}";

echo $str;

and this is how it should look at the end according to the sample.

{"geometry": {"type": "Point", 
              "coordinates": [-104.53702657476524, 1.4311558884747997]
             }, 
              "type": "Feature", 
              "properties": {}
            }

To get the output your after, it's a case of building up a multidimensional array with the right structure so that you can then json_encode() it.

$lat = "52.45238209999999";
$lng = "-1.743507099999988";

$data = ["geometry" => ["type" => "Point",
    "coordinates" => [(float)$lng, (float)$lat]],
    "type" => "Feature",
    "properties" => (object)[]
];

echo json_encode($data, JSON_PRETTY_PRINT);

gives...

{
    "geometry": {
        "type": "Point",
        "coordinates": [
            -1.743507099999988, 52.45238209999999
        ]
    },
    "type": "Feature",
    "properties": {}
}