多维数组 - 获取结构中项目的访问权限

How can I gain access to the 'type' item within the following structure?

The following is output from a foreach, in the variable $item (output from print_r($item);)

Cartthrob_item_product Object ( 
    [core:protected] => Cartthrob_core_ee Object ( 
        [cart] => Cartthrob_cart Object ( 
            [items:protected] => Array ( 
                [3] => Cartthrob_item_product Object ( 
                    [item_options:protected] => Array ( 
                        [type] => product  
                    )
                )
            )
        )
    )
)

Depending on the version of PHP, and assuming the objects have the appropriate getters, you could do:

$item->getCore()->cart->getItems()[3]->getItemOptions()['type'];

If they don't have getters, you can only access Cartthrob_item_product::core, Cartthrob_cart::items, and Cartthrob_item_product::item_options from inside the respective classes themselves because they are protected.

Another possibility is that the Cartthrob_item_product at index 3 is the same object as $item. In that case, assuming the object has the appropriate getter, you'd simply need to do:

$item->getItemOptions()['type'];