I've a result from a webservice's query and I would like to get some values from it. It works but I have PHP notice issues, so I'm probably doing something wrong.
This is the $items
variable content :
stdClass Object
(
[response] => stdClass Object
(
[0] => stdClass Object
(
[id] => 275
[corpid] => 16107
[name] => default
[description] =>
[status] => ok
[nbSteps] => 7
)
[defaultItem] => 275
)
[error] =>
[status] => success
)
So I tried something like :
foreach ( $items->response AS $key => $item ) {
if ( $item->name == 'default' ){ // Line 106
$Id = $item->id;
}
}
It works, $Id
is equal to 275 but PHP returns a notice :
Notice: Trying to get property of non-object in /home/web/dev/webservice-form.php on line 106
Any help would be greatly appreciated.
EDIT : This is the content of the $item variable (taken from the foreach loop) :
stdClass Object
(
[id] => 275
[corpid] => 16107
[name] => default
[description] =>
[status] => ok
[nbSteps] => 7
)
275
Please note that the '275' is a part of the result.