如何解析对象数组中的数据 [英] How to parse data from array of object
问题描述
我的代码中有一个对象$data
的数组.我想收集一些对象属性以在我的网页中打印.这就是为什么我打印dump($data)
这样我就可以看到该模式及其在对象$data
数组中的分布方式.
I have an array of object $data
in my code. I want to collect some of the object attribute to print in my web page. That's why I printed dump($data)
so that I can see the pattern how the object and their attributes distributed in the array of object $data
.
但是在通过dump()
函数看到$data
之后,我无法解析任何内容.
But I could not parse anything from that after seeing $data
through the dump()
function.
使用dump($data)
后,我发现类似...
After using dump($data)
I found something like...
array:1 [▼
0 => {#238 ▼
+"data_": 8
}
]
我需要"data_": 8
以便可以从这里收集8
.为什么有#238
?
它的意义是什么?
I need "data_": 8
so that I can collect 8
from here. Why there is #238
?
What's the significance of it ?
推荐答案
238应该是对象ID.
The 238 should be the object id.
尝试以下代码:
foreach($data as $obj)
{
echo $obj->data_;
}
这篇关于如何解析对象数组中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!