# Calculating the reverse percentage with PHP.

This is a short guide on how to calculate the reverse percentage of a given number.

For example, you have the percentage number (10%) and the result (10). However, you do not have the original number that it came from (100).

Take a look at the following PHP code, which will probably explain it better than words:

```//Our value, which we know is 77%
//of the original number.
\$percentageValue = 72985;

//The percentage value, which
//we already know is 77. This is sometimes
//called the final number.
\$percentage = 77;

//Now, let's calculate the
//original number. i.e. If 72985 is 77%, then
//which number is it 77% of?
\$originalNum = (\$percentageValue / \$percentage) * 100;

//In this case, 72985 is 77% of 94785.71
echo "\$percentageValue is \$percentage of \$originalNum";```

In the code snippet above, we know that 72,985 is 77% of X.

However, we do not know what X is.

In this case, X is the original number that 72,985 came from.

In order to calculate the original number, we need to do a reverse percentage calculation and divide the percentage into the percentage value.

This percentage value is often referred to as the “final number.”

Once we divide the percent into the final number, we simply multiply the result by 100.

This gives us the original number.

If you want the original number in a format that has two decimal places, then you can simply use PHP’s number_format function like so:

```//Round it to two decimal places.
\$originalNum = number_format(\$originalNum, 2);
echo \$originalNum;```

This leaves us with 94,785.71. This makes sense, as 72,985 is 77% of 94,785.71.

To sum up the terms above:

• Final number: 72,985
• Percent: 77%
• Original number: 94,785.71