arrays - PHP json_decode of nested json file -
i have following code , want extract contents of items array inside json file provided bellow btu gives me error.
<?php $url = 'http://api.steampowered.com/ieconitems_570/getplayeritems/v0001?key=7b16accc16bb1008fbe73d39587def7f&steamid=76561198069637917.json'; $content = file_get_contents($url); $json = json_decode($content,true); $output = "<ul>"; foreach ($json['result'][0]['items'] $item) { $output .="<li>".$item['id']."</li>"; $output .="<li>".$item['defindex']."</li>"; $output .="<li>".$item['tradable']."</li>"; echo $items['items']; } $output .="</ul>"; echo $output;
can please help? thank you!
there no item index 'tradable' or 'items' in json data. don't need [0] there.
<?php $url = 'http://api.steampowered.com/ieconitems_570/getplayeritems/v0001?key=7b16accc16bb1008fbe73d39587def7f&steamid=76561198069637917.json'; $content = file_get_contents($url); $json = json_decode($content,true); $output = "<ul>"; foreach ($json['result']['items'] $item) { $output .="<li>".$item['id']."</li>"; $output .="<li>".$item['defindex']."</li>"; //$output .="<li>".$item['tradable']."</li>"; //echo $item['items']; } $output .="</ul>"; echo $output; ?>
Comments
Post a Comment