title: PHP money format add decimal and comma when needed
body: <p>How do I turn this number <strong>247936</strong> into this <strong>$2,479.36</strong> using php?</p>
  
  <p>I tried several options such as:</p>
  
  <pre><code>setlocale(LC_MONETARY, 'en_US');
  echo money_format('%i', '247936'); // OUTPUT: USD 247,936.00 
  </code></pre>
  
  <p>I also tried this</p>
  
  <pre><code>echo number_format(247936, 2);  // echos '247,936.00'
  </code></pre>
  
  <p>I even tried this but it didn't work as well</p>
  
  <pre><code>echo number_format(247936, 2,'.', ','); // echos 247,936.00
  </code></pre>