Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ahmeda's avatar

Calculate percentage between two numbers?

I have these two numbers original one is 1000 the new one is 440

What I want is to get the percentage obtained between two numbers, and I have only calculated the remainder between the two:

function calculatePercentage($original, $given)
{
    $percentChange = (($original - $given) / $original) * 100;

    return round(abs($percentChange)) . '%';
}

The result of calculatePercentage(1000,440) is 56% I need to make it 44%

0 likes
1 reply
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

So this?

$given / $original * 100

Please or to participate in this conversation.