I want to know how can I get the value from this p

2019-08-19 17:16发布

Here's the result of

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

I want to get the value from 0 to Content or 1 to Content , How can I get this?

4条回答
萌系小妹纸
2楼-- · 2019-08-19 17:48
$response->Items->Item->EditorialReviews->EditorialReview[0]->Content
查看更多
乱世女痞
3楼-- · 2019-08-19 17:48

try this:

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 is an array.. use the index of which u want to get the value like...

array[index];

if object use.... ->yourvalue

查看更多
男人必须洒脱
4楼-- · 2019-08-19 17:50

Sounds simple enough:

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

To run through all of them:

foreach($response->Items->Item->EditorialReviews->EditorialReview as $review)
   echo $review->Content;
查看更多
姐就是有狂的资本
5楼-- · 2019-08-19 18:10

Just keep following the chain:

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

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

General rule to finding the data you want from a dump like this:

  1. Anything Array( [x] => ... means you append [0] to your variable.

  2. Anything Object( [x] => ... means you append ->x to your variable.

查看更多
登录 后发表回答