Answer the question
In order to leave comments, you need to log in
how to generate json in php?
Hello. Tell me how to correctly generate a json file so that it looks like this at the output:
{
"type": "FeatureCollection",
"features": [
{"type": "Feature", "id": 0, "geometry": {"type": "Point", "coordinates": [55.831903, 37.411961]}, "properties": {"balloonContent": "Содержимое балуна", "clusterCaption": "Еще одна метка", "hintContent": "Текст подсказки"}},
{"type": "Feature", "id": 1, "geometry": {"type": "Point", "coordinates": [55.763338, 37.565466]}, "properties": {"balloonContent": "Содержимое балуна", "clusterCaption": "Еще одна метка", "hintContent": "Текст подсказки"}},
{"type": "Feature", "id": 2, "geometry": {"type": "Point", "coordinates": [55.763338, 37.565466]}, "properties": {"balloonContent": "Содержимое балуна", "clusterCaption": "Еще одна метка", "hintContent": "Текст подсказки"}},
{"type": "Feature", "id": 3, "geometry": {"type": "Point", "coordinates": [55.744522, 37.616378]}, "properties": {"balloonContent": "Содержимое балуна", "clusterCaption": "Еще одна метка", "hintContent": "Текст подсказки"}}
]
}
Answer the question
In order to leave comments, you need to log in
you create an array with pairs key - value
though in a cycle though where. If you need a subsection in json, then make a nested array.
Well, thenecho json_encode($array);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question