A
A
anthony912020-05-13 10:54:41
PHP
anthony91, 2020-05-13 10:54:41

How to parse an array received via API?

Hello!

We have a form that collects data and sends it via API to a third-party resource, in response we receive information in JSON format.

Array ( [response] => Array ( [items] => Array ( [0] => Array ( [gosnumber] => B170OP29 [mark] => VAZ 211540 [category] => B (M1) [vin] => XTA21154084560272 [data_diagnostic] => 2017-05-19 [sroc_deistvia] => 2018-05-18 [

number_eaisto ] =>
082200051702444 ) ) ) ) : V170OR29
Brand: VAZ 211540
Category: B (M1)
VIN: XTA21154084560272
Diagnostic date: 2017-05-19
Validity: 2018-05-18 EAISTO
number: 082200051702444

Code,

$url = $url_get_kbm2."?".http_build_query($arr_post_out);
        $out_txt = file_get_contents($url);
        $data = json_decode($out_txt,true);
        print_r($data);


I crawled all the forums, but not one solution helped.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2020-05-13
@antony91

$url = $url_get_kbm2."?".http_build_query($arr_post_out);
        $out_txt = file_get_contents($url);
        $data = json_decode($out_txt,true);
        foreach($data['response']['items'] as $val) {
             echo 'Госномер: '.$val['gosnumber'].' / Марка: '.$val['mark'];
        }

A couple like this)
ZY . foreach is if more than one car arrives)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question