我明白如何解析json与PHP,但我不明白如何阅读它的眼睛。有人可以帮我解决这个问题吗?解析JSON结果
这里是我的代码
<?php
$json = file_get_contents('json.txt');
$json_output = json_decode($json);
foreach ($json_output->query as $stf)
{
echo "{$stf->response->domains->name}\n";
}
?>
这里是JSON结果
{ "query" : { "host" : "test.com",
"tool" : "pro"
},
"response" : { "domain_count" : "13",
"domains" : [ { "last_resolved" : "2012-01-11",
"name" : "test1.com"
},
{ "last_resolved" : "2012-01-11",
"name" : "test2.com"
},
的样品正如你可以看到我试着查询 - >应答为>域 - >名称,它没”工作。
我会如何尝试名称?
预先感谢您