Posted by & filed under PHP Development.

We’ve tried many different methods to set precision for a number variable (specifically a currency amount) and we’d like to share the best method we’ve found:

   '1000s_separator' );


number_format( $number, 2, '.', ',' );

Hope this helps!

We have also tried using round( $number, {precision} ) but it ignores zeros(0) within the precision numbers.


$number = 9.90;
round( $number, 2 ); // returns: 9.9

Leave a Reply

Your email address will not be published. Required fields are marked *