title: Thousands separator with printf
body: <p>How do do a thousand separator (like a comma) in a <code>printf</code>?</p>
  
  <p>example:</p>
  
  <pre><code>printf("&lt;td class='number'&gt;%d&lt;/td&gt;", $totals['Sold']); //need thousand separated 
  printf("&lt;td class='number'&gt;%.2f&lt;/td&gt;", $totals['Fees']); //need thousand separated
  </code></pre>
  
  <p><strong>UPDATE</strong> this is what i had originally:</p>
  
  <pre><code>foreach(array_keys($totals) as $key){
          if(is_numeric($totals[$key])){
              $totals[$key] = number_format($totals[$key],2);
          }
      }
  
      echo "&lt;/tbody&gt;
          &lt;tfoot&gt;&lt;tr&gt;";
      echo "&lt;td class='text' colspan='4'&gt;Totals:&lt;/td&gt;";
      echo "&lt;td class='number'&gt;{$totals['Bought']}&lt;/td&gt;";
      echo "&lt;td class='number'&gt;{$totals['Sold']}&lt;/td&gt;";
      echo "&lt;td class='number'&gt;{$totals['Fees']}&lt;/td&gt;";
      echo "&lt;td class='number'&gt;{$totals['Realized']}&lt;/td&gt;";
      echo "&lt;td class='number'&gt;{$totals['Net']}&lt;/td&gt;";
      echo "&lt;td colspan='3'&gt;{$totals['EOD Price']}&lt;/td&gt;";
      echo "&lt;/tr&gt;
          &lt;/tfoot&gt;";
  </code></pre>
  
  <p>and I want it to be come something like:</p>
  
  <pre><code>echo "&lt;/tbody&gt;
          &lt;tfoot&gt;&lt;tr&gt;";
      echo "&lt;td class='text' colspan='3'&gt;Totals:&lt;/td&gt;";
      printf("&lt;td class='number'&gt;%d&lt;/td&gt;", $totals['Bought']) ;
      printf("&lt;td class='number'&gt;%d&lt;/td&gt;", $totals['Sold']) ;
      printf("&lt;td class='number'&gt;%.2f&lt;/td&gt;", $totals['Fees']) ;
      printf("&lt;td class='number'&gt;%.2f&lt;/td&gt;", $totals['Realized']) ;
      printf("&lt;td class='number'&gt;%.2f&lt;/td&gt;", $totals['Net']) ;
      printf("&lt;td colspan='3'&gt;%.2f&lt;/td&gt;", $totals['EOD Price']) ;
      echo "&lt;/tr&gt;
          &lt;/tfoot&gt;";
  </code></pre>
  
  <p>But I need the commas</p>