how do i get the trailing zero to print in the following scenario:
this will print simply 0.7. but i need it to print 0.70.PHP Code:$price = 0.70;
print $price;
sorry if this sounds dumb, been having a tough day. cheers!
| SitePoint Sponsor |
how do i get the trailing zero to print in the following scenario:
this will print simply 0.7. but i need it to print 0.70.PHP Code:$price = 0.70;
print $price;
sorry if this sounds dumb, been having a tough day. cheers!




http://www.php.net/manual/en/function.fprintf.php$money1 = 68.75;
$money2 = 54.35;
$money = $money1 + $money2;
// echo $money will output "123.1";
$formatted = sprintf("%01.2f", $money);
// echo $formatted will output "123.10"





Or you can just use number_format.http://www.php.net/manual/en/function.number-format.phpPHP Code:
$price = 0.70;
echo number_format($price, 2);
thank you for the help![]()
Bookmarks