Jump to content

Real Numbers *.** instead of Integers?


magicmark

Recommended Posts

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 Handling

if (empty($Coupon)) {
$TotalWithShipping = bcadd($Total, $Shipping);

} elseif ( $Coupon == '22001' || $Coupon == '22002' ){

$TotalWithShipping = bcadd($Discounted, $Shipping);
} else {
echo "Invalid Coupon Code!";
}

//Display Result

echo $TotalWithShipping;
Link to comment
https://forums.phpfreaks.com/topic/5781-real-numbers-instead-of-integers/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.