[英]php parse array in object detail
I got stuck on parsing array in my php object 我被困在解析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
)
)
)
)
So how I can fetch all details
indexes 0,1,2 etc 那么我如何获取所有
details
索引0、1,2等
So, you could just iterate over details
as below: 因此,您可以如下遍历
details
:
foreach($your_variable->result->details as $current_detail){
echo $current_detail->account;
// other code here
}
Your data is object if you converto to array u can simply do it 如果您转换为数组,您的数据就是对象,您可以简单地做到这一点
$array=json_decode(json_encode($data),true);
print_r($array);
If just one details key 如果只是一个细节关键
$array=json_decode(json_encode($data),true)
print_r($array['result']['details']);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.