到达对象的元素

时间:2013-09-16 13:19:05

标签: php

如何使用php访问此对象的元素?我已经尝试$obj[0]->trends到达内部数组,但php给了我错误Fatal error: Cannot use object of type stdClass as array in /.....file.php on line 97

   stdClass Object
    (
        [0] => stdClass Object
            (
                [trends] => Array
                    (
                        [0] => stdClass Object
                            (
                                [name] => IWorkAsHardAs
                                [query] => IWorkAsHardAs
                                [events] => 
                            )

                        [1] => stdClass Object
                            (
                                [name] => ProtectOzoneLayer
                                [query] => ProtectOzoneLayer
                                [events] => 
                            )


                    )

                [as_of] => 2013-09-16T13:06:47Z
                [created_at] => 2013-09-16T12:44:57Z
                [locations] => Array
                    (
                        [0] => stdClass Object
                            (
                                [name] => Jaipur
                                [woeid] => 2295401
                            )

                    )

            )

        [httpstatus] => 200
    )

0 个答案:

没有答案