如何从 json 响应数组中提取 id

How to extract id from json response array

如何从此响应中提取 ID。我试过这样但是 return 空白页。以下是我收到的回复。

<?php 
$res = json_decode($sentMessage ,true);
echo $rc = $res[0]['updates']['id'];
?>

回复:

{
    "_": "updates",
    "updates": [{
        "_": "updateMessageID",
        "id": 291,
        "random_id": 8304404519820905816
    }, {
        "_": "updateReadChannelInbox",
        "flags": 0,
        "channel_id": 1763732152,
        "max_id": 291,
        "still_unread_count": 0,
        "pts": 717
    },

$tes 未定义。

<?php 
$res = json_decode($sentMessage ,true);
echo $rc = $res['updates'][0]['id'];
?>

在这里您需要转到更新对象,然后取第一个 (0) 并查找它的 ID。