V
V
Vadim Semennikov2018-03-06 22:34:11
PHP
Vadim Semennikov, 2018-03-06 22:34:11

How to get latest values ​​from json object?

Hello. I work))) with Yandex Direct API. Using the GetWordstatReportList method, I get the resulting response in the form of a json object. Actually he:

{"data": [
          {"ReportID": (int),"StatusReport": (string)}
          {"ReportID": (int),"StatusReport": (string)}
          {"ReportID": (int), "StatusReport": (string)}
       ]
    }

I need to get the latest values ​​using PHP. You need to know the latest knowledge of "ReportID" and "StatusReport". How can this be done correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nick Sdk, 2018-03-06
@VadimRosh

$json_decode = json_decode($json);
$last = end($json_decode->data);
$last_id = $last->ReportID;
$last_status = $last->StatusReport;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question