Fatih
Fatih

Reputation: 235

Php trying to get property of-non-object

I trying to get data from a webservices using php curl. I get this data var_dump($result) result is

string(136) "array(1) { [0]=> object(stdClass)#10 (2) { ["guid"]=>    string(23) "149063186158d93cb600485" ["stage"]=> int(0) } } "

I want to get guid and stage. When I use this code

$result->guid 

I get an error. How can I solve this problem?

Notice: Trying to get property of non-object in

print_r($result) is array(1) { [0]=> object(stdClass)#10 (2) { ["guid"]=> string(23) "149063186158d93cb600485" ["stage"]=> int(0) } }

Upvotes: 0

Views: 1143

Answers (1)

Amir Helmy
Amir Helmy

Reputation: 119

echo (is_array($result)) ? $result[0]->guid : $result->guid;

Upvotes: 1

Related Questions