I have this php
and the $price
maybe 1.0000
i want 1.00
number_format is your best bet.
string number_format ( float $number , int $decimals = 0 , string $dec_point = '.' , string $thousands_sep = ',' )
Example:
<?php echo number_format(1.0000, 2, '.', ','); ?>
number_format works:
echo number_format($price, 2);
The following printf()
call should work for you:
<?php printf("%.2f", $price); ?>
The documentation for this syntax is best described on the sprintf() page.