从对象内的数组获取数组键(protected)-value(来自RTM-php的响应)?

时间:2014-05-22 09:29:22

标签: php arrays object protected

当使用php库进行RTM(https://github.com/bartosz-maciaszek/php-rtm)时,我收到特定任务列表的响应,如下所示:

Rtm\DataContainer Object
(
    [attributes:Rtm\DataContainer:private] => Array
        (
            [0] => Rtm\DataContainer Object
                (
                    [attributes:Rtm\DataContainer:private] => Array
                        (
                            [id] => 19594773
                            [taskseries] => Rtm\DataContainer Object
                                (
                                    [attributes:Rtm\DataContainer:private] => Array
                                        (
                                            [id] => 310899576
                                            [created] => 2013-10-03T05:35:52Z
                                            [modified] => 2013-11-06T17:24:36Z
                                            [name] => A new task
                                            [source] => js
                                            [url] => 
                                            [location_id] =>

                                        )
                                )
                        )
              )
      )
)

我想获得[name]的价值。我该怎么办?

1 个答案:

答案 0 :(得分:1)

据我从文档中可以理解,你必须调用像

这样的东西
$receivedObject->getTaskSeries()->getName()

或者有建议将toArray或toJson应用于返回的对象 - 这应该有效。