Как получить доступ / вывести этот многомерный ассоциативный массив json_decode с помощью PHP - PullRequest
0 голосов
/ 13 сентября 2011

Я пытаюсь получить доступ и вывести ответ JSON:

  1. Я хочу получить значения для [Start] => 0 внутри веб-массива.
  2. Мне также нужно пройти и вывести [результаты] [0] clickurl, заголовок и т. Д.

    Я часами пробовал все типы комбинаций, но безрезультатно.Спасибо за помощь!

      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 ]

0 голосов
/ 13 сентября 2011
echo $var['bossresponse']['web']['start'];
foreach ($var['bossresponse']['web']['results'] as $result) 
  foreach ($result as $key => $value) {
    echo "$key => $value <br>";
  }
}    
0 голосов
/ 13 сентября 2011
$json['bossresponse']['web']['start']
$json['bossresponse']['web']['results'][0]['title']

в foreach ()

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