Calculate percentage saved between two numbers?

2019-03-07 23:41发布

I have two numbers, the first, is the original price, the second, is the discounted price.

I need to work out what percentage a user saves if they purchase at the second price.

example
25, 10 = 60%  
365, 165 = 55%

What I dont know is the formula to calculate this.

标签: math formula
7条回答
爷、活的狠高调
2楼-- · 2019-03-08 00:01
    function calculatePercentage($oldFigure, $newFigure)
{
    $percentChange = (($oldFigure - $newFigure) / $oldFigure) * 100;
    return round(abs($percentChange));
}
查看更多
登录 后发表回答