开发者

How to access/output this json_decode multi dimensional associative array with PHP

开发者 https://www.devze.com 2023-04-04 20:21 出处:网络
I am trying to access and output the JSON response: I want to get to the values for [Start]=>0 inside of the Web array.

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, ...
                                )
                        )
    
                  )
    
           )
    
    )
    


echo $var['bossresponse']['web']['start'];
foreach ($var['bossresponse']['web']['results'] as $result) 
  foreach ($result as $key => $value) {
    echo "$key => $value <br>";
  }
}    


$json['bossresponse']['web']['start']
$json['bossresponse']['web']['results'][0]['title']

in foreach()

foreach($json['bossresponse']['web']['results'] as $j){
     echo "<br>title".$j['title'];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消