【发布时间】:2016-01-12 14:39:14
【问题描述】:
如何预匹配 total_count 来自 php 中的这段代码
{
"data": [
{
"name": "Baptiste Chimay",
"administrator": false,
"id": "10153820811316460"
},
"summary": {
"total_count": 4956
}
}
我试过了,但没有得到任何数据
$url = ('the url i want');
$result = json_decode($url);
$likes = preg_match("'total_count (.*?),'si", file_get_contents($url), $matches);
print_r($url);
【问题讨论】:
-
看起来像(部分)json - 这是该网址的全部输出吗?
-
不是整个输出
-
请添加整个输出。 PHP 原生支持 json,所以正则表达式不是最好的解决方案
标签: php preg-match file-get-contents