title: PHP number_format returns 1.00
body: <p>I have stored in MySQL the number as total(decimal 16,2) 1423.28</p>
  
  <p>I get it display from PHP after making some calculations: </p>
  
  <pre><code>function calculate_balance($total){
  
   //get total paid from another function
   $total_paid = ...
  
   if ($total_paid == 0){
       return $total;
   }else{
       return $total-$total_paid
   }
  
  } 
  
   $balance = calculate_balance($total);
   echo number_format($balance, 2); //returns 1.00
  </code></pre>
  
  <p>I have tried </p>
  
  <pre><code>  number_format((float)$balance, 2);
    number_format(floatval($balance), 2); 
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p><code>var_dump($balance)</code></p>
  
  <p>and I got following output.</p>
  
  <p><code>string(8) "1,423.28" float(152) string(6) "252.00" string(6) "247.50" string(6) "247.50" string(6) "247.50" string(6) "549.90" string(6) "495.00" float(0) string(6) "284.76" float(265)</code></p>
  
  <p>It's working fine without <code>number_format()</code> for value under 1,000.
  E.g.: if balance equal 252.00</p>
  
  <pre><code> echo $balance;
  </code></pre>
  
  <p>output</p>
  
  <p>252.00</p>