Saturday, 15 May 2010

Unable to get number of likes in an array php -



Unable to get number of likes in an array php -

i using next code number of likes on page.

<?php $site="http://graph.facebook.com/?ids=http%3a%2f%2fxxxxxxxx/svce.php"; $graph= file_get_contents($site); $json_string=$graph; $array = json_decode($json_string, true); //echo "<pre>"; //print_r($array); $var = $array['shares']; echo $var; ?>

but whenever seek echo out next code. unidentified index notice following: notice: undefined index: shares in c:\xampp\htdocs\graphapi.php on line 19

where going wrong?

here's print_r output:

array ( [http://xxxxxxxxx/svce.php] => array ( [id] => http://xxxxxxxxx/svce.php [shares] => 7 [comments] => 3 ) )

according print out looks there array more in $array. seek this;

echo $array['http://xxxxxxxxx/svce.php']['shares'];

php arrays facebook multidimensional-array

No comments:

Post a Comment