Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Backpack.tf Pricelist</title>
- <meta charset="UTF-8">
- <style type="text/css">
- td {
- border: 1px solid #000;
- }
- </style>
- </head>
- <body>
- <table>
- <thead>
- <tr>
- <th>Item name</th>
- <th>Defindex</th>
- <th>Quality</th>
- <th>Tradable</th>
- <th>Craftable</th>
- <th>Priceindex</th>
- <th>Value</th>
- </tr>
- </thead>
- <tbody>
- <?php
- $bptf_data = file_get_contents ('./bptf_api.json');
- $bptf_api = json_decode($bptf_data, true);
- $bptf_items = $bptf_api['response']['items'];
- foreach ($bptf_items as $item_name => $bptf_item) {
- /* Loop through the defindices for item, some items such
- * as the Shotgun and Rocket Launcher have multiple defindices */
- foreach ($bptf_item['defindex'] as $defindex) {
- // Loop through the qualities in the price
- foreach ($bptf_item['prices'] as $quality => $quality_price) {
- // Loop through tradable/untradable values
- foreach ($quality_price as $tradable => $tradable_price) {
- // Convert the tradable/untradable string to a boolean
- $item_tradable = ($tradable == 'Tradable');
- // Loop through craftable/uncraftable values
- foreach ($tradable_price as $craftable => $craftable_price) {
- // Convert the craftable/uncraftable string to a boolean
- $item_craftable = ($craftable == 'Craftable');
- /* Loop through price indices. The price index is used for
- * particle effects, and crate series number. In most cases
- * this will be 0. */
- foreach ($craftable_price as $priceindex => $item_price) {
- /* Finally we've looped through all the attributes!
- * This is where price values and currencies are stored. */
- $currency = $item_price['currency'];
- $value = $item_price['value'];
- $value_high = $item_price['value_high'];
- echo "<tr>";
- echo "<td>$item_name</td>";
- echo "<td>$defindex</td>";
- echo "<td>$quality</td>";
- echo "<td>$item_tradable</td>";
- echo "<td>$item_craftable</td>";
- echo "<td>$priceindex</td>";
- echo "<td>$value";
- if ($value_high) { echo "-$value_high"; }
- echo " $currency</td>";
- echo "</tr>";
- }
- }
- }
- }
- }
- }
- ?>
- </tbody>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment