如何解析和显示评论

时间:2012-03-29 10:40:44

标签: php

帮助,我的思绪变得疯狂。如何解析注释并显示它。

stdClass Object
(
[stream] => stdClass Object
    (
        [id] => 521734635_403433313001586
        [from] => stdClass Object
            (
                [name] => Jonathan Rosario
                [id] => 521734635
            )

        [message] => What if we do the same action in our country?...i just hope they be fair. Its just unfair that they also ban our Bibles while we never ban their Qu'rans in our country.
        [comments] => stdClass Object
            (
                [data] => Array
                    (
                        [0] => stdClass Object
                            (
                                [id] => 521734635_403433313001586_90696065
                                [from] => stdClass Object
                                    (
                                        [name] => ''
                                        [id] => 570761262
                                    )

                                [message] => test
                                [created_time] => 2012-03-29T10:01:49+0000
                            )

                        [1] => stdClass Object
                            (
                                [id] => 521734635_403433313001586_90696070
                                [from] => stdClass Object
                                    (
                                        [name] => Alwaynne Kevin
                                        [id] => 100000364267158
                                    )

                                [message] => Oo nga...bakit ganyan sila...hahah.!
                                [created_time] => 2012-03-29T10:07:52+0000
                            )

                        [2] => stdClass Object
                            (
                                [id] => 521734635_403433313001586_90696146
                                [from] => stdClass Object
                                    (
                                        [name] => Jp Peña
                                        [id] => 100000599584313
                                    )

                                [message] => they're just doing what the "christian" crusaders did to them.
                                [created_time] => 2012-03-29T10:33:12+0000
                            )

                    )

                [count] => 3
            )

        [picture] => http://external.ak.fbcdn.net/safe_image.php?d=AQCr7a57qDUU2MHR&w=90&h=90&url=http%3A%2F%2Fwww.interaksyon.com%2Fassets%2Fimages%2Farticles%2Finterphoto_1332546902.jpg
        [name] => Top Saudi cleric 'issues fatwa' on Christian churches; Bishops alarmed - InterAksyon.com
        [description] => Christian bishops are sharply criticizing Saudi Arabia's top religious official after reports that he issued a fatwa saying all churches on the Arabian Peninsula should be destroyed. At least 3.5 million Christians live in the Gulf Arab region. They are mostly Catholic workers from the Philippines a...
        [created_time] => 2012-03-29T10:00:41+0000
    )

)

1 个答案:

答案 0 :(得分:3)

你在评论中得到了整个对象列表,所以试试下面的内容:

foreach( $yourObj->stream->comments as $comment){
   echo sprintf('%s: %s', $comment->from->name, $comment->message);
}