Soru & Cevap

PHP JSON ÇIKTI ALMA ...

20.08.2019 - 02:44

Merhabalar,

Aşağıdaki formatta json çıktı üreten sayfam mevcut. Veritabanından çekilen verilere göre bu çıktıyı ürretmem gerekiyor. Ancak json için bulduğum hiç bir örnekte bu tip bi çıktı benzeri göremedim. İşin içinden çıkmadım :)

 

<?php
$array = array (
      'type' => 'FeatureCollection',
      'features' => 
      array (
       
	   0 => 
        array (
          'type' => 'Feature',
          'id' => 0,
          'geometry' => 
          array (
            'type' => 'Point',
            'coordinates' => 
            array (
              0 => 41.008475,
              1 => 29.048195,
            ),
          ),
          'properties' => 
          array (
            'balloonContent' => 'Turgut (Kurye)',
            'clusterCaption' => 'Pharmacy',
            'hintContent' => 'Pharmacy',
            'iconCaption' => 'Turgut (Kurye)',
          ),
          'options' => 
          array (
            'preset' => 'islands#blueBicycleIcon',
            'iconColor' => 'yellow',
          ),
        ),
		
        1 => 
        array (
          'type' => 'Feature',
          'id' => 1,
          'geometry' => 
          array (
            'type' => 'Point',
            'coordinates' => 
            array (
              0 => 41.088277,
              1 => 29.076911,
            ),
          ),
          'properties' => 
          array (
            'balloonContent' => 'Sezai (Şoför)',
            'clusterCaption' => 'Sezai (Şoför)',
            'hintContent' => 'Sezai (Şoför)',
            'iconCaption' => 'Sezai (Şoför)',
          ),
          'options' => 
          array (
            'preset' => 'islands#blueDeliveryIcon',
            'iconColor' => 'blue',
          ),
        ),
		

		
		
      ),
    );

$json = json_encode($array);

echo $json;
?>

 

225 Görüntülenme

1 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

picture-259959-1585770739.jpg
ertan.kocakoc
04.09.2019 - 02:21
$result = mysql_query("SELECT * FROM persons");
 
$json = array();
$total_records = mysql_num_rows($result);
 
if($total_records > 0){
  while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
    $json[] = $row;
  }
}
 
echo json_encode($json);