2016-08-22 83 views
-1

嘗試從JSON接收的結果中打印記錄。下面是JSON的結果我想打印[resourceName][get] from [v1.1.0] => Array 我怎樣才能得到這個工作的格式使用PHP打印JSON結果

我得到的$result = json_decode($result,true);

Array 
(
    [title] => API Directory 
    [description] => This directory contains links for Product Feed API and Delta Feed API of all categories with all the versions available 
    [apiGroups] => Array 
     (
      [affiliate] => Array 
       (
        [name] => affiliate 
        [apiListings] => Array 
         (
          [food_nutrition] => Array 
           (
            [availableVariants] => Array 
             (
              [v0.1.0] => Array 
               (
                [resourceName] => food_nutrition 
                [get] => 
                [deltaGet] => 
                [top] => 
                [post] => 
                [put] => 
                [delete] => 
               ) 

              [v1.1.0] => Array 
               (
                [resourceName] => food_nutrition 
                [get] => 
                [deltaGet] => 
                [top] => 
                [post] => 
                [put] => 
                [delete] => 
               ) 

             ) 

            [apiName] => food_nutrition 
           ) 
         ) 

       ) 

     ) 

) 

?請指教。

+0

類似'echo $ result ['apiGroups'] ['affiliate'] ['apiListings'] ['food_nutrition'] ['availableVariants'] ['v1.1.0'] ['resourceName']'? – bzeaman

回答

0
echo $result['apiGroups']['affiliate']['apiListings']['food_nutrition']['availableVariants']['v1.1.0']['resourceName']; 
echo $result['apiGroups']['affiliate']['apiListings']['food_nutrition']['availableVariants']['v1.1.0']['get']; 

不是很漂亮,但總之,這是一個多維數組畢竟。

+0

['food_nutrition']不是靜態的。其他類別有更多的節點。 –

+1

這就像在有人射門得分後移動門柱! – RamRaider