2016-05-15 10 views
0

PHPのページに表示するapiからのjson応答があります。私はそれをする方法を知りたいです。私が持っているjsonの応答は次のようになります:すでに解析済みのJSON応答を表示

stdClass Object 
(
    [resultsFound] => 10 
    [resultsStart] => 0 
    [resultsShown] => 10 
    [delivery] => 9 
    [dineOut] => 9 
    [nightlife] => 0 
    [chillout] => 0 
    [takeaway] => 10 
    [all] => 10 
    [results] => Array 
     (
      [0] => stdClass Object 
       (
        [result] => stdClass Object 
         (
          [id] => 310160 
          [name] => Andhra Biryani House 
          [address] => Shop 144, The Sapphire Mall, Opposite Orchid Petals, Sector 49, Near Sohna Road, Gurgaon 
          [locality] => Sohna Road 
          [hasOnlineDelivery] => 1 
          [onlineDeliveryLink] => https://www.zomato.com/ncr/andhra-biryani-house-sohna-road-gurgaon/order 
          [phone] => +91 9650508883 
          [city] => Gurgaon 
          [cuisines] => Biryani, Hyderabadi, Andhra 
          [distance_actual] => 0 
          [distance_friendly] => about 0 meters 
          [rating_aggregate] => 3.7 
          [votes] => 258 
          [rating_color] => 5BA829 
          [rating_text] => Very Good 
          [user_review_count] => 171 
          [rating_editor_overall] => 0 
          [cost_for_two] => 700 
          [has_discount] => 0 
          [has_citibank_discount] => 0 
          [has_emirates_discount] => 0 
          [latitude] => 28.4117236642 
          [longitude] => 77.0484169945 
          [has_menu] => 1 
          [has_bar] => 0 
          [is_pure_veg] => 0 
          [accepts_credit_card] => 0 
          [has_dine_in] => 1 
          [has_delivery] => 1 
          [has_coordinates] => 1 
          [image_470_310] => 
          [image_310_310] => 
          [image_310_150] => 
          [image_150_150] => 
         ) 

       ) 
) 

このデータをPHPのページに表示するには、いくつかの提案が必要です。

答えて

0

PHPはリクエストを送信するクライアントにHTTP経由で印刷します。一般的に、クライアントはHTMLを読むことができるブラウザなので、HTMLページにコンテンツを表示すると仮定します。個人的に好きなのは、PHPのテンプレートスタイルを使ってページを準備し、それをクライアントに送ることです。次のようなことをしてください:

<html> 
    <head> 
    <!--something--> 
    </head> 
    <body> 
     <!-- more something --> 
     <?php echo $myObject->locality;?> 
     <!-- and so on --> 
    </body> 
</html> 
関連する問題