0

The following is the response I received using Amazon API PHP

{"ItemsResult":{"Items":[{"ASIN":"B07HGGYWL6","DetailPageURL":"https://www.amazon.in/dp/B07HGGYWL6?tag=nextshop09-21&linkCode=ogi&th=1&psc=1","Images":{"Primary":{"Medium":{"Height":160,"URL":"https://m.media-amazon.com/images/I/41+xWzgV8jL._SL160_.jpg","Width":77}}},"ItemInfo":{"Title":{"DisplayValue":"Samsung Galaxy M31 (Ocean Blue, 6GB RAM, 128GB Storage) - Get Flat Rs 2,500 Instant Discount with select bank cards - Limited Period Offer","Label":"Title","Locale":"en_IN"}},"Offers":{"Listings":[{"Id":"DC6ZAXF6qNdlESLD4vdkiZ4DT0gujZt676%2FhqlbuHpFUc5JDIwpeO0HYeSkcvgeAdXGmWOYc%2FO6DtZxzchM7rvuLPPr5b7Ffmzg2QjBFyU3W24n71nhOwIPUTsI3%2BqTuCfsMSKNtdPoisjWpvceuBxoa%2FFvCQCjX","Price":{"Amount":16499.0,"Currency":"INR","DisplayAmount":"₹ 16,499.00","Savings":{"Amount":1000.0,"Currency":"INR","DisplayAmount":"₹ 1,000.00 (6%)","Percentage":6}},"ViolatesMAP":false}]}}]}}

It is a result of simple echo $response;

How can I echo the "ItemInfo":{"Title" only ?

The result of $title should be "Samsung Galaxy M31 (Ocean Blue, 6GB RAM, 128GB Storage) - Get Flat Rs 2,500 Instant Discount with select bank cards - Limited Period Offer". or the result of $price should be "16499.0"

I am getting confused with JSON array!

  • 1
    Does this answer your question? [How do I extract data from JSON with PHP?](https://stackoverflow.com/questions/29308898/how-do-i-extract-data-from-json-with-php) – catcon Nov 04 '20 at 05:55
  • https://3v4l.org/LB8nc – Nick Nov 04 '20 at 05:57
  • @Nick, this worked and very very useful. Thank you – Mithun P Nov 04 '20 at 06:13
  • @MithunP no worries - I'm glad it was useful. I really recommend you spend some time reading the posted duplicate, it has a good explanation of the generic method to get to the answer in that demo. – Nick Nov 04 '20 at 06:28

0 Answers0