Canman2005 Posted March 28, 2006 Share Posted March 28, 2006 Hi allI have a calculation that I do, it look like[code]<?php$subtotal = 33;$delivery = 45;$total = $subtotal + $delivery;echo $subtotal;?>[/code]How could I remove 20% from the $total? So it would look something like[code]$total = $subtotal + $delivery + 20%;[/code]Is this easy to do?Thanks in advanceEd Link to comment https://forums.phpfreaks.com/topic/5993-php-percentages/ Share on other sites More sharing options...
wildteen88 Posted March 28, 2006 Share Posted March 28, 2006 You'll want to do this:[code]<?php$subtotal = 33;$delivery = 45;$total = $subtotal + $delivery;echo 'Subtotal: ' . $subtotal . '<br />';echo 'Total: ' . $total . '<br />20% off: ';//take 20% off from $total, 20% of $total is 15.60echo $total - ($total/100*20);?>[/code] Link to comment https://forums.phpfreaks.com/topic/5993-php-percentages/#findComment-21493 Share on other sites More sharing options...
Eddyon Posted March 28, 2006 Share Posted March 28, 2006 Or just do $total*0.8, that will give you the same effect but is just shorter. Link to comment https://forums.phpfreaks.com/topic/5993-php-percentages/#findComment-21539 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.