0

这是$object微软返回给我的:

object(Microsoft\Graph\Model\Event)#56 (1) {
  ["_propDict":protected]=>
  array(2) {
    ["@odata.context"]=>
    string(245) "https://graph.microsoft.com/v1.0/$metadata#users('email%40outlook.com')/calendars('AAAAAAAAAAAAAAAAAAAAAAAA')/calendarView"
    ["value"]=>
    array(0) {
    }
  }
}

我正在尝试检查value' 的数组中是否包含任何内容。我无法访问“值”,因为它只是说数组。这是我已经尝试过的事情:

$object->array;

$object->array();

$object[0];

foreach ($object as $key) {
    var_dump($key);
}

这些都不起作用。


我正在尝试做这样的事情:

if(empty($object->array['value'])) {
    echo 'value is empty';
}
4

1 回答 1

0

Entity.getProperties()函数可用于返回属性列表的目的。 Entity是实体的类。Event

array_key_exists以下示例演示如何使用function确定实体是否包含属性:

$requestUrl = "https://graph.microsoft.com/v1.0/drives/$targetDriveId";
$drive = $this->client->createRequest("GET", $requestUrl)
     ->setReturnType(Model\Drive::class)
     ->execute();

$properties = $drive->getProperties();  //get all properties
if (array_key_exists('id', $properties)) { //verify for id property
    print $properties["id"];
}
于 2018-11-14T10:20:03.230 回答