I have a website that allows people to buy items for specific games. And i have a page that shows all available stock on 200+ items. The information comes from the Steam API.
I use this code to count the items available.
$count_foundingFather = 0;
foreach($hatbot1_array['result']['items'] as $item){
if($item['defindex'] == 30142){
$count_foundingFather++;
}
}
It counts the items on how many times the items DefIndex number is found.
The JSON array that is returned from the API is huge and makes the page loading time take a really long time. Plus, having to use that chunk of code for each item makes it take even longer.
Is there a way i can make the item counting faster or do it separate from every time a person loads the page?