0

I have an object array (shown at the bottom) and can access the data by doing this:

echo $MyVariable->id;
echo $MyVariable->type;

and so on. However, I can't access the item [count] by doing this:

echo $MyVariable->id;

Anybody know why? Count seems to be used for something else, a count perhaps?

  stdClass Object (
[id] => 573948779291487 
[from] => stdClass Object (
[category] => Bar 
[category_list] => Array (
[0] => stdClass Object (
[id] => 218693881483234 
[name] => Pub 
) 
[1] => stdClass Object (
[id] => 164049010316507 
[name] => Gastropub 
) ) 
[name] => The Melbourne Arms 
[id] => 533195070033525 
) 
[name] => The Melbourne Arms Gallery 
[location] => The Melbourne Arms 
[place] => stdClass Object (
[id] => 533195070033525 
[name] => The Melbourne Arms 
[location] => stdClass Object (
[street] => Main Street 
[city] => Melbourne 
[country] => United Kingdom 
[zip] => YO42 4QJ 
[latitude] => 53.8872441 
[longitude] => -0.8554097 
) ) 
[link] => http://www.facebook.com/album.php?fbid=573948779291487&id=533195070033525&aid=1073741825 
[cover_photo] => 573948812624817 
[count] => 28 
[type] => normal 
[created_time] => 2013-03-13T22:22:45+0000 
[updated_time] => 2013-03-13T22:34:40+0000 
[can_upload] => 
[likes] => stdClass Object (
[data] => Array (
[0] => stdClass Object (
[id] => 1361671776 
[name] => Lesley Maiden 
) 
[1] => stdClass Object (
[id] => 518580863 
[name] => Diane Maiden 
) 
[2] => stdClass Object (
[id] => 1254875611 
[name] => Vanessa Wilson 
) 
[3] => stdClass Object (
[id] => 533195070033525 
[name] => The Melbourne Arms 
) 
[4] => stdClass Object (
[id] => 100001664649752 
[name] => Bowen Lee 
) ) 
[paging] => stdClass Object (
[next] => https://graph.facebook.com/573948779291487/likes?limit=25&offset=25&__after_id=100001664649752 
) ) ) 1
1
  • Where you add in the output of print_r, it's best if you can preserve the indentation by using <pre> tags - it makes it much more readable :). Commented Mar 15, 2013 at 22:24

1 Answer 1

0

Try handling your data differently

$data  = file_get_contents("https://graph.facebook.com/573948779291487");
$data = json_decode($data, true);
echo $data['count'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.