如何从这个数组中获取数据(stdClass)php ??
Array
(
[0] => stdClass Object
(
[id] => 4
[programs] => FireFox
[version] => 4.00
[type] => Browsers
[description] => fdmkfdsf,sdfdsfdsfdsf
dfdsf
sd
f
dsf
ds
f
[views] => 2
[serial] => 434343-343434-3434-c
)
)
当我尝试使用foreach获取它时,我收到了该错误
#
A PHP Error was encountered
Severity: 4096
Message: Object of class stdClass could not be converted to string
Filename: views/results.php
Line Number: 2
如何获取程序数据(例如FireFox)??
答案 0 :(得分:3)
$data = (your data);
echo $data[0]->programs;
答案 1 :(得分:0)
如果您想将此$data
用作数组,则应将其更改为
$val = json_decode(json_encode($data),true);//to convert stdClass object into array
echo"<pre>";
print_r($val) //print the value of $val
echo $val['program']; //Now you can use it as array in your code