Приветствую! Сам код: PHP: $json = array('type'=>'Feature','id'=>1,'geometry'=>array('type'=>'Point','coordinates'=>array(55.755814,37.617635 )), 'properties'=>array('balloonContent'=>'Russia','clusterCaption'=>'None','hintContent'=>'Russia')); $json[] = array('type'=>'Feature','id'=>2,'geometry'=>array('type'=>'Point','coordinates'=>array(55.755814,37.617635 )), 'properties'=>array('balloonContent'=>'Russia','clusterCaption'=>'None','hintContent'=>'Russia')); exit(json_encode(array('type'=>'FeatureCollection','features'=>array($json)))); Результат: HTML: {"type":"FeatureCollection","features":[{"type":"Feature","id":1,"geometry":{"type":"Point","coordinates":[55.755814,37.617635]},"properties":{"balloonContent":"Russia","clusterCaption":"None","hintContent":"Russia"},"0":{"type":"Feature","id":2,"geometry":{"type":"Point","coordinates":[55.755814,37.617635]},"properties":{"balloonContent":"Russia","clusterCaption":"None","hintContent":"Russia"}}}]} Надо результат как здесь: HTML: { "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": "Текст подсказки"}} ] } Как убрать индекс (если я правильно его назвал) из моего кода? Заранее благодарю.
Ну только если к первому $json добавить[] PHP: $json[]= array('type'=>'Feature','id'=>1,'geometry'=> array('type'=>'Point','coordinates'=>array(55.755814,37.617635 )), 'properties'=> array('balloonContent'=>'Russia','clusterCaption'=>'None','hintContent'=>'Russia')); $json[] = array('type'=>'Feature','id'=>2,'geometry'=> array('type'=>'Point','coordinates'=>array(55.755814,37.617635 )), 'properties'=> array('balloonContent'=>'Russia','clusterCaption'=>'None','hintContent'=>'Russia')); echo "<pre>"; exit(json_encode(array('type'=>'FeatureCollection','features'=>array($json)),JSON_PRETTY_PRINT)); Результат Код (Text): { "type": "FeatureCollection", "features": [ [ { "type": "Feature", "id": 1, "geometry": { "type": "Point", "coordinates": [ 55.755814, 37.617635 ] }, "properties": { "balloonContent": "Russia", "clusterCaption": "None", "hintContent": "Russia" } }, { "type": "Feature", "id": 2, "geometry": { "type": "Point", "coordinates": [ 55.755814, 37.617635 ] }, "properties": { "balloonContent": "Russia", "clusterCaption": "None", "hintContent": "Russia" } } ] ] }