Possible Duplicate:
PHP number_format is rounding?
I need a PHP function to convert numbers into currency format like so:
444 output 444.00
444.156 output 444.15
0 output 0.00
It should not round off the last decimal digit.
Possible Duplicate:
PHP number_format is rounding?
I need a PHP function to convert numbers into currency format like so:
444 output 444.00
444.156 output 444.15
0 output 0.00
It should not round off the last decimal digit.
try number_format method. It will get the job done for you.
$number = 444.657;
$format_number = number_format($number, 2, '.', '');
// 444.66
substr(number_format($number, 3, '.', ''), 0, -1);
//444.65