Php如何在print_r中打印数组响应

时间:2018-03-07 13:44:06

标签: php

我得到了这样的回复,现在我要打印

[products]如何打印

我试试 print_r($ response [' products']);

我的回复

stdClass Object
(
    [users] => Array
        (
            [0] => stdClass Object
                (
                    [username] => admin
                    [firstName] => admin
                    [lastName] => admin


                    [products] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [name] => 1
                                    [url] => mytest.html
                                )

                            [1] => stdClass Object
                                (
                                    [name] => 2
                                    [url] => mytest.html
                                )

                            [2] => stdClass Object
                                (
                                    [name] => 3
                                    [url] => mytest.html
                                )

                            [3] => stdClass Object
                                (
                                    [name] => 4
                                    [url] => mytest.html
                                )

                            [4] => stdClass Object
                                (
                                    [name] => 5
                                    [url] => mytest.html
                                )

                            [5] => stdClass Object
                                (
                                    [name] => 6
                                    [url] => mytest.html
                                )

                            [6] => stdClass Object
                                (
                                    [name] => 7
                                    [url] => mytest.html
                                )

                        )
                )

        )

    [error] => 
    [errorMessage] => 
)

1 个答案:

答案 0 :(得分:2)

试试这个

print_r($response->users['0']->products);