簡體   English   中英

php解析對象詳細信息中的數組

[英]php parse array in object detail

我被困在解析php對象中的數組

stdClass Object
(
    [result] => stdClass Object
        (
            [details] => Array
                (
                    [0] => stdClass Object
                        (
                            [account] => 
                            [address] => add1
                            [category] => receive
                            [amount] => 1100
                            [label] => 
                            [vout] => 1
                        )

                    [1] => stdClass Object
                        (
                            [account] => 
                            [address] => add2
                            [category] => receive
                            [amount] => 11600
                            [label] => 
                            [vout] => 2
                        )

                    [2] => stdClass Object
                        (
                            [account] => 
                            [address] => add3
                            [category] => receive
                            [amount] => 1000
                            [label] => 
                            [vout] => 4
                        )

                )
        ) 
)

那么我如何獲取所有details索引0、1,2等

因此,您可以如下遍歷details

foreach($your_variable->result->details as $current_detail){
   echo $current_detail->account;
   // other code here
}

如果您轉換為數組,您的數據就是對象,您可以簡單地做到這一點



$array=json_decode(json_encode($data),true); 

print_r($array);

如果只是一個細節關鍵

$array=json_decode(json_encode($data),true)


print_r($array['result']['details']);


暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM