Note that there are some explanatory texts on larger screens.

plurals
  1. POGet value in mutli array
    primarykey
    data
    text
    <p>How would i get the value of a key in an array?</p> <p>The array is done by google shopping api which is:</p> <pre><code>// Valid source values are "public", "cx:cse", and "gan:pid" // See http://code.google.com/apis/shopping/search/v1/getting_started.html#products-feed $source = "public"; // For more information about full text search with the shopping API, please // see http://code.google.com/apis/shopping/search/v1/getting_started.html#text-search $query = "\"mp3 player\" | ipod"; //The order in which the API returns products is defined by a ranking criterion. // See http://code.google.com/apis/shopping/search/v1/getting_started.html#ranking $ranking = "relevancy"; $results = $service-&gt;products-&gt;listProducts($source, array( "country" =&gt; "UK", "q" =&gt; $query, "rankBy" =&gt; $ranking, )); print "&lt;h1&gt;Shopping Results&lt;/h1&gt;&lt;pre&gt;" . print_r($results, true) . "&lt;/pre&gt;"; </code></pre> <p>I have the following array which outputs: Shopping Results</p> <pre><code>Array ( [kind] =&gt; shopping#products [etag] =&gt; "*********" [id] =&gt; tag:google.com,2010:shopping/products [selfLink] =&gt; https://www.googleapis.com/shopping/search/v1/public/products?country=UK&amp;q=iphone&amp;rankBy=relevancy [nextLink] =&gt; https://www.googleapis.com/shopping/search/v1/public/products?country=UK&amp;q=iphone&amp;rankBy=relevancy&amp;startIndex=26 [totalItems] =&gt; 771622 [startIndex] =&gt; 1 [itemsPerPage] =&gt; 25 [currentItemCount] =&gt; 25 [requestId] =&gt; 0CMjH976CqbECFYNWtAodLRwAAA [items] =&gt; Array ( [0] =&gt; Array ( [kind] =&gt; shopping#product [id] =&gt; tag:google.com,2010:shopping/products/5735617/11254757413841304510 [selfLink] =&gt; https://www.googleapis.com/shopping/search/v1/public/products/5735617/gid/11254757413841304510 [product] =&gt; Array ( [googleId] =&gt; 11254757413841304510 [author] =&gt; Array ( [name] =&gt; Amazon.co.uk [accountId] =&gt; 5735617 ) [creationTime] =&gt; 2012-05-04T05:03:50.000Z [modificationTime] =&gt; 2012-07-20T02:02:16.000Z [country] =&gt; GB [language] =&gt; en [title] =&gt; Apple iPod touch 8GB - Black - 4th Generation (Latest Model - Launched Sept 2010) [description] =&gt; Apple iPod touch 8GB - Black - 4th Generation (Latest Model - Launched Sept 2010) [link] =&gt; http://www.amazon.co.uk/dp/B0040GIZTI/ref=asc_df_B0040GIZTI8843997?smid=A1YZ4RXO7GUOYN&amp;tag=googlecouk06-21&amp;linkCode=asn&amp;creative=22218&amp;creativeASIN=B0040GIZTI [brand] =&gt; Apple [condition] =&gt; new [gtin] =&gt; 00885909394739 [gtins] =&gt; Array ( [0] =&gt; 00885909394739 ) [mpns] =&gt; Array ( [0] =&gt; MC540BT/A ) [inventories] =&gt; Array ( [0] =&gt; Array ( [channel] =&gt; online [availability] =&gt; inStock [price] =&gt; 135.95 [shipping] =&gt; 1.99 [currency] =&gt; GBP ) ) [images] =&gt; Array ( [0] =&gt; Array ( [link] =&gt; http://ecx.images-amazon.com/images/I/41p2rNmazRL.jpg [status] =&gt; available ) ) ) ) [1] =&gt; Array ( [kind] =&gt; shopping#product [id] =&gt; tag:google.com,2010:shopping/products/5735617/4597224105326146239 [selfLink] =&gt; https://www.googleapis.com/shopping/search/v1/public/products/5735617/gid/4597224105326146239 [product] =&gt; Array ( [googleId] =&gt; 4597224105326146239 [author] =&gt; Array ( [name] =&gt; Amazon.co.uk [accountId] =&gt; 5735617 ) [creationTime] =&gt; 2012-05-04T05:03:50.000Z [modificationTime] =&gt; 2012-07-20T02:02:16.000Z [country] =&gt; GB [language] =&gt; en [title] =&gt; SanDisk Sansa Clip+ 8GB MP3 Player with Radio and Expandable MicroSD/SDHC Slot - Black [description] =&gt; 8 GB memory Digital FM-tuner with 40 preset radio stations Extendable microSD/microSDHC card slot [link] =&gt; http://www.amazon.co.uk/dp/B002NX0ME6/ref=asc_df_B002NX0ME68843997?smid=A3P5ROKL5A1OLE&amp;tag=googlecouk06-21&amp;linkCode=asn&amp;creative=22206&amp;creativeASIN=B002NX0ME6 [brand] =&gt; SanDisk [condition] =&gt; new [gtin] =&gt; 00619659059989 [gtins] =&gt; Array ( [0] =&gt; 00619659059989 ) [mpns] =&gt; Array ( [0] =&gt; SDMX18-008G-E46K ) [inventories] =&gt; Array ( [0] =&gt; Array ( [channel] =&gt; online [availability] =&gt; inStock [price] =&gt; 46.95 [shipping] =&gt; 0 [currency] =&gt; GBP ) ) [images] =&gt; Array ( [0] =&gt; Array ( [link] =&gt; http://ecx.images-amazon.com/images/I/419U6bYDF1L.jpg [status] =&gt; available ) ) ) ) </code></pre> <p>I don't need all this data i just need 3-4 of the keys but how would i access them? How would i echo the value of say [title] from each array?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload