0

我正在尝试获取我网站上特定页面的点赞数并将其存储在一个数组中。卡在中间,我发现我可以通过以下代码获取喜欢的数量以及其他数据:

/*$site="http://graph.facebook.com/?ids=http%3a%2f%2xxxxxxxx.com/abc.php";
$graph= file_get_contents($site);

输出如下:

{"http:\/\/xxxxxxxx.com\/abc.php":{"id":"http:\/\/xxxxxxxx.com\/abc.php","shares":75,"comments":3}}

有没有办法我可以只存储喜欢的数量,即在这种情况下为 75 的 php 数组?

我试过explode(); 但问题是我将使用的 url 的长度不会是恒定的。

4

1 回答 1

1

这是一个 json 字符串解码它,使用 json_decode 你将得到输出为数组。参考: http: //php.net/manual/en/function.json-decode.php

$array  = json_deocde($json_string, true);

echo "<pre>";
print_r($array);
于 2013-02-15T12:20:50.633 回答