3

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 program(e.g FireFox)??

1

2 Answers 2

3
$data = (your data);

echo $data[0]->programs;
Sign up to request clarification or add additional context in comments.

1 Comment

i tried but it give me that A PHP Error was encountered Severity: Notice Message: Trying to get property of non-object Filename: controllers/Serials.php Line Number: 82
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.