如何编辑JSON查询

时间:2019-10-18 13:16:57

标签: php json

我如何到达affiliate_info1对象?谁能帮我吗?

    stdClass Object
    (
        [status] => 1
        [httpStatus] => 200
        [data] => stdClass Object
            (
                [page] => 1
                [current] => 1
                [count] => 1
                [pageCount] => 1
                [data] => Array
                    (
                        [0] => stdClass Object
                            (
                                [Stat] => stdClass Object
                                    (
                                        [affiliate_info1] => riHPLAieOoKkeXMKKiNPiA
                                    )

                            )

                        [1] => stdClass Object
                            (
                                [Stat] => stdClass Object
                                    (
                                        [affiliate_info1] => XCuAQTtLkWTIKYMWKESlQS
                                    )

                            )

                        [2] => stdClass Object
                            (
                                [Stat] => stdClass Object
                                    (
                                        [affiliate_info1] => XCuAQTtLkWTIKYMWKESlQS
                                    )

                            )


                    )

                [dbSource] => branddb
            )

        [errors] => Array
            (
            )

        [errorMessage] => 
    )  

foreach($json as $item){

print_r($item->data);

}

1 个答案:

答案 0 :(得分:0)

foreach($myObject->data->data as $row){
    echo $row->Stat-> affiliate_info1;
}

您可以在data嵌套数组中进行简单循环,并检索嵌套对象的值。

我想当对象中嵌套数组时,您会感到困惑。