Home > Mobile >  Get the percentage between 2 numbers
Get the percentage between 2 numbers

Time:09-11

I am trying to figure out if there is a way to find the percentage between 2 numbers.

It's a progress / ranking system.

I want to find the percentage the $current_exp is between the $current_min and the $current_max values, is there a way to achieve this in PHP? So far I've got to this, but it doesn't work as you progress in ranks, it doesn't treat the $current_min as 0 so when you rank up, it says you are like 75% into your next rank progression when you're in fact 0. Does this make sense?

$currentProg = ($current_exp * 100) / $current_max; 

Say the current minimum is 18750 and the current maximum is 25100, the current exp is 22000... What percentage from the min to the max is the current exp? This will change each rank as the $current_min and $current_max variables get set depending on the exp of the user.

The next rank is Current min is 25100 Current max is 34230

Currently, when you are at 26000 exp, the output is saying 75.956763073327% which is not correct, it should be like 1 or 2%?

Thanks in advance

  •  Tags:  
  • php
  • Related