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:
number_format( {number}, {precision}, 'decimal_separator', '1000s_separator' );
Example:
number_format( $number, 2, '.', ',' );
Hope this helps!
We have also tried using round( $number, {precision} ) but it ignores zeros(0) within the precision numbers.
Example:
$number = 9.90; round( $number, 2 ); // returns: 9.9