开发者

how can i fetch data from this array (stdClass) php?

how can i fetch data from this array (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
        )

)

when i tried to fetch it using foreach i got that error

#
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

How can i get the data of the pr开发者_开发技巧ogram(e.g FireFox)??


$data = (your data);

echo $data[0]->programs;


If you want to use this $data as array then you should change it as

$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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜