php - needing to make only 2 decimal points instead of 4 -
i trying have 2 decimal points on if statement right shows 4 places after decimal point depending if subtotal * .45 = out be.
if ($paymethod == $paypal) { echo "shipping & handling = ".($grandtotal * .045); $grandtotal = $grandtotal * 1.045; } elseif ($paymethod == $check) { echo "shipping & handling = 0"; } ?><br />
this if statement needing .$$ <two decimal places only>
right shows 4 places
number_format rounding you; use floatval()
turn float after being converted string.
<?php $paymethod = "paypal"; $grandtotal = 45; if ($paymethod == "paypal") { echo "shipping & handling = " . number_format(($grandtotal * .045), 2); $grandtotal = floatval(number_format(($grandtotal * 1.045), 2)); } elseif ($paymethod == "check") { echo "shipping & handling = 0"; } ?><br />
Comments
Post a Comment