Take json element with PHP

Asked

Viewed 222 times

2

I made a print_r() of a json result that gave the following:

stdClass Object
(
    [status] => 1
    [resultado] => stdClass Object
        (
            [BUSCA_BIN] => stdClass Object
                (
                    [BUSCA_BIN] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [ITEM_ID] => MVT1687

[...]

I’d like to take the element ITEM_ID, but is always returning NULL.

How I’m trying:

var_dump($json->resultado->BUSCA_BIN->BUSCA_BIN->ITEM_ID);

//RESULTA UM NULL.

What I do?

1 answer

1


The last BUSCA_BIN is a array, example:

var_dump($json->resultado->BUSCA_BIN->BUSCA_BIN[0]->ITEM_ID);

Reference: PHP - array

  • 1

    I had done it and it didn’t work. Now it did. Thank you for the reply.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.