'How to extract id from json response array
How to extract id from this response. I tried like this But return blank page. Below is the response what I'm getting.
<?php
$res = json_decode($sentMessage ,true);
echo $rc = $res[0]['updates']['id'];
?>
Response :
{
"_": "updates",
"updates": [{
"_": "updateMessageID",
"id": 291,
"random_id": 8304404519820905816
}, {
"_": "updateReadChannelInbox",
"flags": 0,
"channel_id": 1763732152,
"max_id": 291,
"still_unread_count": 0,
"pts": 717
},
Solution 1:[1]
$tes is not defined.
<?php
$res = json_decode($sentMessage ,true);
echo $rc = $res['updates'][0]['id'];
?>
Here you need to go to updates object, then take the first one (0) and look for its id.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |