php - Iterating through amazon shopping API (big multi-dimensional array) through print_r -


I always had trouble retrieving prices in the API-returned array, usually because they are very complex I < / P>

I am not posting the entire array here. But this is a summary below.

Just to let you know, I have tried to hunt nests of many forward lapses, but I am getting many errors and I can not imagine that there is no easy way to do this.

Thanks for your help in advance. > Sample of output:

   Array ([HTTPHeaders] => Array ([header] => Hey ([name] = & gt; User agent [value] => PHP-SOAP / 5.2 .17)) [RequestId] => a2d742d5-64b7-4de7-9c3d-a4c1cd525e7e [logic] => array ([argument] => array ([name] => service [value] = & Gt; AWSECommerceService) [RequestProcessingTime] = & gt; [0.382574] [item] => Aare ([request] => array ([IsValid] => True [Modish spacing] => Hey ([condition] => New [DeliveryMethod] = & gt; Ship [keyword] = & gt; TV [Merchant ID] => Amazon [Response group] => Small [Review Notification] = & gt; - submissions date [Searchindex ] => All =) gt; = 16,647 [total page] = & gt; 166438 [item] => array ([0] => array ([ASIN] => B 0036WT3P2 [detail page] = & gt; http://www.amazon.com/Samsung-LN40C630-40-Inch-1080p- black / DP / B0036WT3P2% 3FSubscriptionId% 3DAKIAJQJSA2B4JHSRNEXQ% 26tag% 3Dws% 26linkCode% 3Dsp1% 26camp % 3D2025% 26creative% 3D165953% 26creativeASIN% 3DB0036WT3P2 [ItemLinks] = & gt; Array ([ItemLink] => Array ([0] => Array ([details] => Technical Details [URL] => http://www.amazon.com/Samsung-LN40C630- 40-Inch-1080p-Black / dp / tech-data / B0036WT3P2% 3FSubscriptionId% 3DAKIAJQJSA2B4JHSRNEXQ% 26tag% 3Dws% 26linkCode% 3Dsp1% 26camp% 3D2025% 26creative% 3D386001% 26creativeASIN% 3DB0036WT3P2) [1] = & gt; array ([ Description] => Add to Baby Registry [URL] = & gt; http://www.amazon.com/gp/registry/baby/add-item.html%3Fasin.0%3DB0036WT3P2%26SubscriptionId%3DAKIAJQJSA2B4JHSRNEXQ % 26tag% 3Dws% 26linkCode% 3Dsp1% 26camp% 3D2025% 26creative% 3D386001% 26creativeASIN% 3DB0036WT3P2) [2] = & gt; Array ([Description] => Add to Wedding Registry [URL] = & gt; http: //www.amazon.com/gp/registry/Wedding /AdMedica% 3Fatin.0.0% 3 DB0036WT3P2% 26 Member ID% 3 Dikeajejejes 2B 4 Jeacsaranakskyu 26% Tags% 3Dws% 26 Linkkod% 3Dsp1% 26camp% 3D2025% 26creative% 3D386001% 26creativeASIN% 3DB0036WT3P2) [3] = & gt; Array ([description] = & Gt; Add to wishlist [url] = & gt; Actiteepi://wwwkameznkcom/gp/rjistry/bislist/aed-aitmkhtml% 3Fasin.0% 3DB0036WT3P2% 26SubscriptionId% 3DAKIAJQJSA2B4JHSRNEXQ% 26tag% 3Dws% 26linkCode% 3Dsp1% 26camp% 3D2025% 26creative% 3D386001% 26creativeASIN% 3DB0036WT3P2) [4] = & gt; Array ([description] = & gt; Tell A Friend [URL] = & gt; http://www.amazon.com/gp/pdp/taf/B0036WT3P2%3FSubscriptionId%3DAKIAJQJSA2B4JHSRNEXQ%26tag%3Dws%26linkCode%3Dsp1 % 26camp% 3D2025% 26creative% 3D386001% 26creativeASIN% 3DB0036WT3P2) [5] = & gt; Array ([description] = & gt; All customer reviews [URL] = & gt; http://www.amazon.com/review/product/B0036WT3P2%3FSubscriptionId%3DAKIAJQJSA2B4JHSRNEXQ%26tag%3Dws%26linkCode%3Dsp1%26camp%3D2025 % 26creative% 3,386001% 26creativeASIN% 3DB0036WT3P2) [6] = & gt; Array ([description] = & gt; all offer [url] = & gt; http://www.amazon.com/gp/offer-listing/B0036WT3P2%3FSubscriptionId%3DAKIAJQJSA2B4JHSRNEXQ%26tag%3Dws%26linkCode%3Dsp1%26camp% 3D2025% 26creative% 3D386001% 26creativeASIN% 3DB0036WT3P2))) [Item Properties] = & gt; Array ([creator] = & gt; Samsung [product group] = & gt; CE [title] => Samsung LN 40C630 40-inch 1080p 120Hz LCD HDTV (Black))? & Gt;   

I ItemAttributes-> I'm trying to retrieve the title part and DetailPageURL.

Thank you.

Try it, I think whatever you want, will do it, though I have not tested it. / P>

  $ amazon_array = $ your_big_ass_amazon_array; // Change this with ananye that you show in your post $ items = $ your_big_ass_amazon_array ['item']; Forex Currency ($ item $ as item) {$ ItemAttributes = getSubArrayByIndex ($ item, 'ItemAttributes'); $ Titles [] = $ item attribute ['title']; } Print_r ($ title); Function getSubArrayByIndex ($ array, $ index) {if (!! Is_array (array $)) empty return; If (isset ($ array [$ index])) $ array [$ index]; Forex Currency ($ array as $ item) {$ return = getSubArrayByIndex ($ item, $ index); If (! Is_null ($ return)) {return $ return; }} Return tap; }    

Comments