title: PHP JSON Format Currency Comma
body: <p>I'm new to PHP.</p>
  
  <p>My code reads a price value from a Steam game's json data.</p>
  
  <pre><code>http://store.steampowered.com/api/appdetails/?appids=8870
  </code></pre>
  
  <p>Problem is that the value of the price node is not formatted with a comma separator for dollars and cents. My code works to piece together the dollars and cents but is it the right way to do it for this instance. Also if there is another easier method of doing my newbie code, feel free to show me where it can be improved. Thanks!</p>
  
  <pre><code>&lt;?php
  
  $appid = '8870';
  
  $ht = 'http://store.steampowered.com/api/appdetails/?appids=' . $appid;
  
  $fgc = file_get_contents($ht);
  $jd = json_decode($fgc, true);
  
  $gdata = $jd[$appid]['data'];
  
  $gname = $gdata['name'];
  $gprice = $gdata['price_overview']['final'];
  $gdesc = $gdata['detailed_description'];
  
  $gusd = substr($gprice, 0, -2);
  $gcent = substr($gprice, 2);
  
  echo $gname. '&lt;br&gt;';
  echo 'Price: $' .$gusd. ',' .$gcent;
  
  ?&gt;
  </code></pre>
  
  <p>If I may ask another question... can the price data aka $gprice be added to another price data that is fetched, to return a total.</p>