我被困在我的 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 等
2 回答
![?](http://img1.sycdn.imooc.com/5458477300014deb02200220-100-100.jpg)
喵喵时光机
TA贡献1846条经验 获得超7个赞
所以,你可以迭代details如下:
foreach($your_variable->result->details as $current_detail){
echo $current_detail->account;
// other code here
}
![?](http://img1.sycdn.imooc.com/545869390001b87802200220-100-100.jpg)
缥缈止盈
TA贡献2041条经验 获得超4个赞
如果您转换为数组,您的数据就是对象,您可以简单地做到这一点
$array=json_decode(json_encode($data),true);
print_r($array);
如果只有一个细节键
$array=json_decode(json_encode($data),true)
print_r($array['result']['details']);
- 2 回答
- 0 关注
- 190 浏览
添加回答
举报
0/150
提交
取消