Jump to content

[SOLVED] Percentages


bachx

Recommended Posts

This is more of a mathmatical question but if anyone knows, I'd really appreciate it.

 

Say I have two numbers, for example 150 and 450....and a third number between them, say 250. I want to calculate the percentage of 250 between 150 and 450, where 150 is the 0%, and 450 is the 100%. I know there is a certain formula, but seeing math was never my favorite course, I can't just figure it out.  :)

Link to comment
https://forums.phpfreaks.com/topic/65783-solved-percentages/
Share on other sites

Huge sigh:

 

$whole_thing = $high_num - $low_num; // the range, or 100%, e.g. 450-150=300
$part_thing = $some_number - $low_num; // the unknown bit of the range, e.g. 250-150=100
$percent = 100 * $part_thing / $whole_thing;// .g. 100*100/300 = 33.33%

 

Worked like a charm. Thanks!  :)

Link to comment
https://forums.phpfreaks.com/topic/65783-solved-percentages/#findComment-328676
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.