Reputation: 5299
I new in php.
Try parse a stdClass Object:
$datastoresArray = $geoserver->listDataStores($item->name);
foreach ($datastoresArray as $dstores){
if($dstores->dataStore != null){
$dstore = $dstores->dataStore;
foreach ($dstore as $item){
echo " - ".$item->name."\n";
}
}
}
In this line if($dstores->dataStore != null){
i get error Traing to get property of non-object
. Becouse somethimes i not have a dataStore
in $dstores
. How to know what i have dataStore
and whan dont have?
Upvotes: 1
Views: 152
Reputation: 1371
Try to use:
if(!empty($dstores->dataStore))
or
if(isset($dstores->dataStore))
Upvotes: 2