Вытащить значения из объекта json

yaski

web3
Регистрация
21 Фев 2010
Сообщения
658
Реакции
500
Имеется вот такой объект
Код:
stdClass Object
(
    [status] => 1
    [message] => OK
    [result] => Array
        (
            [0] => stdClass Object
                (
                    [address] => 0x0b357c8b6d2170e9e1064556f4dcc26d0c38fafa
                    [topics] => Array
                        (
                            [0] => 0xa4aee4c40a9346000546ce1743f64d90b90bd769fa0f9e02381dbbb95cb8533f
                            [1] => 0x0000000000000000000000000000000000000000000000000000000000000001
                        )

                    [data] => 0x
                    [blockNumber] => 0x475e00
                    [timeStamp] => 0x5c1e346f
                    [gasPrice] => 0x3b9aca00
                    [gasUsed] => 0x38b6b
                    [logIndex] => 0x7
                    [transactionHash] => 0x22539b9eaa7723c969604be01274075d924e862a286f545a5d8989592e4dc0fc
                    [transactionIndex] => 0x7
                )

            [1] => stdClass Object
                (
                    [address] => 0x0b357c8b6d2170e9e1064556f4dcc26d0c38fafa
                    [topics] => Array
                        (
                            [0] => 0xa4aee4c40a9346000546ce1743f64d90b90bd769fa0f9e02381dbbb95cb8533f
                            [1] => 0x0000000000000000000000000000000000000000000000000000000000000001
                        )

                    [data] => 0x
                    [blockNumber] => 0x475e2e
                    [timeStamp] => 0x5c1e37d5
                    [gasPrice] => 0x3b9aca00
                    [gasUsed] => 0x8c21
                    [logIndex] => 0x1d
                    [transactionHash] => 0xe9950ce3a77866c2df152bd7822812470c658b1a5bd7565b9a1e910912e5bec0
                    [transactionIndex] => 0x31
                )

            [2] => stdClass Object
                (
                    [address] => 0x0b357c8b6d2170e9e1064556f4dcc26d0c38fafa
                    [topics] => Array
                        (
                            [0] => 0xa4aee4c40a9346000546ce1743f64d90b90bd769fa0f9e02381dbbb95cb8533f
                            [1] => 0x0000000000000000000000000000000000000000000000000000000000000001
                        )

                    [data] => 0x
                    [blockNumber] => 0x475e38
                    [timeStamp] => 0x5c1e38d5
                    [gasPrice] => 0x3b9aca00
                    [gasUsed] => 0x7961
                    [logIndex] => 0x13
                    [transactionHash] => 0x825bec97fd087bb9d05197a07195f3f494a4a00d0e4e5cd6203f96a453409db8
                    [transactionIndex] => 0x10
                )

            [3] => stdClass Object
                (
                    [address] => 0x0b357c8b6d2170e9e1064556f4dcc26d0c38fafa
                    [topics] => Array
                        (
                            [0] => 0xa4aee4c40a9346000546ce1743f64d90b90bd769fa0f9e02381dbbb95cb8533f
                            [1] => 0x0000000000000000000000000000000000000000000000000000000000000001
                        )

                    [data] => 0x
                    [blockNumber] => 0x475e5e
                    [timeStamp] => 0x5c1e3b9b
                    [gasPrice] => 0x98bca5a00
                    [gasUsed] => 0xce98
                    [logIndex] => 0x
                    [transactionHash] => 0x0e455b33ee27461979c9e029c6bc5642510614cd584e77ca61963f3c1ff9476a
                    [transactionIndex] => 0x1
                )

        )

)
Помогите с циклом foreach. Нужно вытащить в переменные $blockNumber и $topics[1] соответствующие значения.
 
json_decode, а дальше массив.
Я бы через for перебирал, а результаты в массив, или выводить по очереди:
for $i бла, бла, бла
$bn = $result[$i][blocknumber];
$tp = $result[$i][topics][1]
 
Назад
Сверху