我的代码:
$json_response = json_decode($response, true); $tag= $json_response['results']['tags'][0]['tag']; print $tag;
我的JSON:
{ "results": [ { "tagging_id": null, "image": "image.jpg", "tags": [ { "confidence": 100, "tag": "herb" }, { "confidence": 98.3637619018555, "tag": "plant" } ] } ] }
我想输出“赫伯”。我查阅了一些例子,但不知道错误在哪里。
我在看结果,然后是树。
你必须把里面的第一个元素 ['results'] .
['results']
echo $json_response['results'][0]['tags'][0]['tag'];