user2964771
user2964771

Reputation: 1

json array not displaying the values

I have the following json array, I am trying to retrive the values but it does not work

 => Array (
    [url] => http://chrome.blogspot.com/feeds/posts/default
    [title] => <b>Google</b> Chrome <b>Blog</b>

This is the code I am using in php to retrive the values

$json = json_decode($res, true);

echo $json['url'];

Can some one help on this.

Upvotes: 0

Views: 92

Answers (2)

Vijay Verma
Vijay Verma

Reputation: 3698

Please debug the $json via print_r($json); and then check current status of array and their indexes.

Upvotes: 0

Arun Killu
Arun Killu

Reputation: 14233

Its any array of arrays

echo $json[0]['url'];

From the comment

Array ( [responseData] =>
            Array ( [query] => Official Google Blogs 
                              [entries] => Array ( [0]=>


 echo $json['responseData']['entries'][0]['url'];

To display all the values you have to loop through each entries

foreach($json['responseData']['entries'] as $data)
{
  echo $data['url'];
}

Upvotes: 2

Related Questions