magicmark Posted March 25, 2006 Share Posted March 25, 2006 Please Please Please help me make this script display a real number as the result without using normal + & - PHP e.g. $Total + $Shipping?//Variables$Coupon = '22002';$Total = 149;$Shipping = 12.50;//20% Discount Calculation$Discount = bcmul($Total, '0.2');$Discounted = bcsub($Total, $Discount);//If Statement for Criteria, Compulsory Inputs or Handlingif (empty($Coupon)) {$TotalWithShipping = bcadd($Total, $Shipping);} elseif ( $Coupon == '22001' || $Coupon == '22002' ){$TotalWithShipping = bcadd($Discounted, $Shipping);} else {echo "Invalid Coupon Code!";}//Display Resultecho $TotalWithShipping; Quote Link to comment Share on other sites More sharing options...
annihilate Posted March 25, 2006 Share Posted March 25, 2006 You need to pass the scale parameter to set the number of digits after the decimal point on some of the functions.For example:[code]$Discount = bcmul($Total, '0.2', 2);$Discounted = bcsub($Total, $Discount, 2);[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.