I am using a API to get deals from a shopping website and I get the following JSON response -
{
"update_time": "2020-07-23 22:01:31",
"offers": [{
"products": [{
"title": "Product Name",
"endDate": "2020-07-24 03:55:01",
"url": "https://store.com/productid",
"offerPercent": 87,
"offerPrice": "12.74",
"id": "3cbfdc55",
"normalPrice": "99.99",
"reviewRating": 4.7428455,
"imageUrl": "https://store.com/productid/image",
"totalReviews": "1856"
}, { //This repeats alot of times
I am tried to use PHP to:
1 Retrieve the data into PHP
2 Loop through all of the items, storing all of the parameters, like url, title etc.
3 Concatenate that with some html (like a div tag) e.g:
$html = '';
$html = $html . '<div>Title' . $title .'</div>'; //Repeating this for each item?
Is that possible, if so, how? Could you point me in the right direction?
Edit:
I used json_decode to convert the json to php ($someArray json_decode($jsonlink, true); then I used foreach to read the contents
foreach ($someArray as $key => $value) {
echo $value[1][1];
}
And the webpage showed up as blank. What am I doing wrong.