doudui6756 2011-09-13 19:44
浏览 50
已采纳

如何使用PHP访问/输出这个json_decode多维关联数组

I am trying to access and output the JSON response:

  1. I want to get to the values for [Start]=>0 inside of the Web array.
  2. I also need to go through and output the [results][0]clickurl,title etc.

    I have spent hours now trying all types of combinations to no avail. Thanks for the help!

      Array
        (
    [bossresponse] => Array
        (
            [responsecode] => 200
            [web] => Array
                (
                    [start] => 0
                    [count] => 14
                    [totalresults] => 14
                    [results] => Array
                        (
                            [0] => Array
                                (
                                    [date] => 
                                    [clickurl] => http://url.com/1
                                    [url] => http://url.com/1
                                    [dispurl] => http://url.com/1...
                                    [title] => Title of Content 1
                                    [abstract] => This is the summary, This is the summary,    This is the summary, ...
                                )
    
                            [1] => Array
                                (
                                    [date] => 
                                    [clickurl] => http://url.com/2
                                    [url] => http://url.com/2
                                    [dispurl] => http://url.com/2...
                                    [title] => Title of Content 2
                                    [abstract] => This is the summary, This is the summary,  This is the summary, ...
                                )
                        )
    
                  )
    
           )
    
    )
    
  • 写回答

2条回答 默认 最新

  • donglu6805 2011-09-13 19:49
    关注
    echo $var['bossresponse']['web']['start'];
    foreach ($var['bossresponse']['web']['results'] as $result) 
      foreach ($result as $key => $value) {
        echo "$key => $value <br>";
      }
    }    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services