0

这是结果

print_r($response->Items->Item->EditorialReviews->EditorialReview)

 Array
        (
            [0] => stdClass Object
                (
                    [Source] => Product Description
                    [Content] => Acer AO725-0899
                    [IsLinkSuppressed] => 
                )

            [1] => stdClass Object
                (
                    [Source] => Amazon.com Product Description
                    [Content] => Perfect portability, perfect usability: The Aspire® One AO725 N

我想获得从 0 到 Content 或 1 到 Content 的值,我怎样才能得到这个?

4

4 回答 4

1

继续关注链:

$response->Items->Item->EditorialReviews->EditorialReview[0]->Content

$response->Items->Item->EditorialReviews->EditorialReview[1]->Content

从转储中查找所需数据的一般规则如下:

  1. 任何东西Array( [x] => ...都意味着你附加[0]到你的变量。

  2. 任何东西Object( [x] => ...都意味着你附加->x到你的变量。

于 2012-10-12T08:08:47.917 回答
1
$response->Items->Item->EditorialReviews->EditorialReview[0]->Content
于 2012-10-12T08:08:49.700 回答
1

听起来很简单:

echo $response->Items->Item->EditorialReviews->EditorialReview[0]->Content;

要遍历所有这些:

foreach($response->Items->Item->EditorialReviews->EditorialReview as $review)
   echo $review->Content;
于 2012-10-12T08:09:03.627 回答
1

试试这个:

echo $response->Items->Item->EditorialReviews->EditorialReview[0]->Content;  //for 0 contect
echo $response->Items->Item->EditorialReviews->EditorialReview[1]->Content;  //for 1 content

$response->Items->Item->EditorialReviews->EditorialReview是一个数组..使用您想要获取值的索引...

数组[索引];

如果对象使用.... ->yourvalue

于 2012-10-12T08:10:06.290 回答