PHP - 检查对象数组的最有效方法

I have a large array of objects which I need to efficiently check:

  1. If a property exists within the object
  2. To get the value

A simplified version of data structure would look like:

[0] => stdClass Object
        (
            [ID] => 1222
            [name] => Foo
            [pass] => stdClass Object
                      (
                          [ID] => 1234
                          [type] => Foo
                      )
         )

[1] => stdClass Object
        (
            [ID] => 2333
            [name] => Bar
            [pass] => stdClass Object
                      (
                          [ID] => 4567
                          [type] => Foo
                          [flag] =>  1
                      )
        )

Let's say we need to check if 'flag' exists and get the value.

I'm currently achieving what I need by iterating through the structure using a foreach loop, but I'm looking to make efficiencies.