我在电报机器人中询问php中的照片个人资料图片时收到此文件json
,我只想保存一些有关它的信息。
这是代码:
{
"ok": true,
"result": {
"total_count": 16,
"photos": [
[
{
"file_id": "2342423423252",
"file_size": 13038,
"width": 160,
"height": 160
},
{
"file_id": "2342423423252",
"file_size": 13038,
"width": 160,
"height": 160
},
{
"file_id": "2342423423252",
"file_size": 13038,
"width": 160,
"height": 160
}
],
[
{
"file_id": "2342423423252",
"file_size": 13038,
"width": 160,
"height": 160
},
{
"file_id": "2342423423252",
"file_size": 13038,
"width": 160,
"height": 160
},
{
"file_id": "2342423423252",
"file_size": 13038,
"width": 160,
"height": 160
}
],
...
我必须只保存file_id
,但我不知道该怎么做。
不一定都是file_id,只需一次! 对不起,我的英语不好.. 有人可以帮帮我吗?
答案 0 :(得分:3)
$x = json_decode($yourJSON, true);
$id = $x["result"]["photos"][0][0]["file_id"]