1
Well, I’ll try to explain my doubt to myself in the best way:
<?php
$steamid = 76561198337627631;
$prices = file_get_contents('prices.txt');
$prices = json_decode($prices, true);
$inv = curl('https://steamcommunity.com/profiles/'.$steamid.'/inventory/json/730/2/');
$inv = json_decode($inv, true);
$items = array();
foreach ($inv['rgInventory'] as $key => $value) {
$id = $value['classid'].'_'.$value['instanceid'];
$trade = $inv['rgDescriptions'][$id]['tradable'];
if(!$trade) continue;
$name = $inv['rgDescriptions'][$id]['market_hash_name'];
$price = $prices['response']['items'][$name]['value']*10;
$img = 'http://steamcommunity-a.akamaihd.net/economy/image/'.$inv['rgDescriptions'][$id]['icon_url'];
$items[] = array(
'assetid' => $value['id'],
'bt_price' => "0.00",
'img' => $img,
'name' => $name,
'price' => $price,
'reject' => $reject,
'sa_price' => $price,
'steamid' => $steamid);
}
// curl
function getTemplate($name, $in = null) {
extract($in);
ob_start();
include "template/" . $name;
$text = ob_get_clean();
return $text;
}
function curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
?>
I have the following code, and I intend to echo my array items, showing all parameters of it, however it has to be in while because I have several items, how can I do this?
Thank you.
But yours with several items will only be composed at the end of that right while? Why not
foreach
after the while and there you can print each parameter of each item– Miguel
Could you give me an example for kindness?
– Gonçalo