This function accepts actual price and discounted price as parameters and returns percentage value.
Function
function percentage($actual_price, $discounted_price){ return abs(round(((($discounted_price - $actual_price) * 100) / $actual_price), 0)); }
Calling The Function
percentage(100, 75).'%';
Output
25%
Leave A comment
Email address is optional and will not be published. Only add email address if you want a reply from blog author.
Please fill required fields marked with *