2012-10-12 38 views
0

顯示此的print_r獲得的價值這是我想從0獲得的價值內容或1至內容,怎樣的我想知道我怎麼可以從下面

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 

結果我可以得到這個嗎?

回答

1

只要保持鏈如下:

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

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

一般規則,從這樣的轉儲找到你想要的數據:

  1. 任何Array([x] => ...意味着你追加[0]到您的變量。

  2. 任何Object([x] => ...表示您將->x附加到您的變量。

+0

感謝先生:) --- –

+1

@SuiGo沒問題,更新我的回答可以幫助您通過未來'print_r'輸出找到自己的方式。 –

+0

是的,我真的很困惑的是lols..now我知道:) –

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

謝謝! ,:) - X –

1

聽起來很簡單:

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

要通過所有的人都跑:

foreach($response->Items->Item->EditorialReviews->EditorialReview as $review) 
    echo $review->Content; 
+0

謝謝,現在我知道了:) –

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是一個數組..使用的u的想要得到的值等的索引......

陣列[指數];

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

+0

謝謝,現在我知道了:) –