0

我如何遍历这个对象并阅读conversion_id. 我尝试了以下foreach,但我似乎做错了。

<?php
    foreach( $result->response->data as $key=>$value ) {
        echo $value->Stat->conversion_id.' ';
    }
?>





stdClass Object
(
    [response] => stdClass Object
        (
            [status] => 1
            [data] => stdClass Object
                (
                    [data] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [Stat] => stdClass Object
                                        (
                                            [conversion_id] => 351140
                                        )
                                )

                            [1] => stdClass Object
                                (
                                    [Stat] => stdClass Object
                                        (
                                            [conversion_id] => 355704
                                        )
                                }
                        )
                )
        )

)
4

2 回答 2

2

你想迭代$result->response->data->data

于 2012-10-31T21:32:30.870 回答
2

您错过了“数据”和“统计”对象:

<?php
    foreach( $result->response->data->data as $key=>$value ) {
        echo $value->Stat->conversion_id;
    }
?>
于 2012-10-31T21:32:35.293 回答