Answer the question
In order to leave comments, you need to log in
How to make the correct formation of a php array?
Hello. I form an array in PHP in this way:
<?php
$massiv = array();
foreach($deliveries as $delivery){
$massiv[] = array(
"type"=>"Feature",
"id" => $delivery->id,
"geometry" => array(
"type" => "Polygon",
"coordinates" => $delivery->map
)
);
};
$result = array("type" => "FeatureCollection","features" => $massiv);
echo json_encode( $result );
?>
"id":12
it turns out "id":"12"
{"type":"FeatureCollection","features":[{"type":"Feature","id":"12","geometry":{"type":"Polygon","coordinates":"[]"}},{"type":"Feature","id":"13","geometry":{"type":"Polygon","coordinates":"[]"}}]}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question