So i have been having troubles with seeing if a user has more than one of the same sticker in their inventory using the Steam Web API.
http://steamcommunity.com/profiles/76561198188713228/inventory/json/730/2
My current code works perfectly fine when displaying any other item that has an amount greater than one, but when it comes to displaying a sticker it will only display one on the site.
Here is my code:
$Steam_inv= file_get_contents($urls[2]);
$Steam_Json = json_decode($Steam_inv, true);
echo "User is logged in (steamID: $matches[1])
";
//var_dump($Steam_Json['rgDescriptions']['1989271297_0']['market_name']);
$TotalItems = 0;
foreach ($Steam_Json['rgDescriptions'] as $item){
$TotalItems++;
$itemBD = json_encode($item);
$itemAD = json_decode($itemBD, true);
$result = json_encode($itemAD['market_name']);
$result = str_replace('"', " ", json_encode($itemAD['market_name']));
$result = str_replace('Factory New', "FN", $result);
$result = str_replace('Minimal Wear', "MW", $result);
$result = str_replace('Field-Tested', "FT", $result);
$result = str_replace('Well-Worn', "WW", $result);
$result = str_replace('Battle-Scarred', "BS", $result);
$result = str_replace('\u2122', " ", $result);
$result = str_replace('\u2605', " ", $result);
$WepType = json_encode($itemAD['tags'][0]['internal_name']);
$WepType = str_replace('"', "", $WepType);
if($WepType != "CSGO_Type_WeaponCase" && $WepType != "CSGO_Type_Knife")
{
$colors = json_encode($itemAD['tags'][4]['color']);
$colors = str_replace('"', "", $colors);
}
elseif ($WepType == "CSGO_Type_Knife"){
$colors = "FFD700";
$result = "★" . $result;
}
$pics = json_encode($itemAD['classid']);
$pics = str_replace('"', "", $pics);
echo "<p style='color:#$colors;position:relative;left:50%;'>" . $result . "</p>" . "<img class='Guns' src='https://steamcommunity-a.akamaihd.net/economy/image/class/730/$pics'></img>";
}
echo $TotalItems;
Sorry if its sloppy, im really new to PHP.