sprintf %0.2f : sprintf « Development « PHP






sprintf %0.2f


<?
$tax = 1.06;
$subtotal = 10.94;
$total = $tax + $subtotal;
$fmt_total = sprintf ("%0.2f", $total);
echo "$fmt_total";
?>
           
       








Related examples in the same category

1.Type Specifiers for printf() and sprintf()
2.sprintf: Regards the string an integer and formats it as a binary number
3.sprintf: Considers the string an integer and formats it with that ASCII value
4.sprintf: Considers the string an integer and formats it as a decimal number