-1

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.

Community
  • 1
  • 1
Swapnil
  • 151
  • 1
  • 3
  • 9

1 Answers1

1

try number_format method. It will get the job done for you.

$number = 444.657;

$format_number = number_format($number, 2, '.', '');
// 444.66

Without Rounding

substr(number_format($number, 3, '.', ''), 0, -1);
//444.65
Techie
  • 44,706
  • 42
  • 157
  • 243