i'm working with an external API that provides me some information,
That information has some items that gives me normal items with one backpack, and others without.
This is an example of the json response:
With backpack
"featured": [
{
"id": "CID_641_Athena_Commando_M_SweaterWeather",
"name": "Rodolfo",
"price": 1200,
"image": "$$$URL$$$",
"otherItemsDetails": [
{
"name": "Guirlanda Explosiva",
"images": {
"icon": "$$$URL$$$",}
}
]
},
Without backpack
{
"id": "Pickaxe_ID_137_NutCracker",
"name": "Globo de Neve",
"price": 800,
"image": "$$$URL$$$",
"otherItemsDetails": []
},
So i'm currently using foreach
$backpack = $item['otherItemsDetails'][0]['images']['icon'];
and
<?php
if(isset($backpack)){
echo "<img height='50' width='50' src='$backpack;' class='sec'>";
}
else{
}
?>
But it keeps giving me the "Undefined offset: 0".
Thanks!