[英]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.