Jump to content

Percentage between two numbers?


lynxus

Recommended Posts

Hi Guys,

 

I have two values.

1) Number of users connected. ( Ex: 3456 )

2) Number of users configured. ( Ex: 4100 )

 

How can I show this as a percentage. Ie: there are X% users connected. ( A percentage of the total configured )

 

 

Now, my maths is normally good but i just dont trust my workings lol.

 

Ive been doing :  $percent = $connected / $configured * 100;

 

 

Thanks

L

Link to comment
https://forums.phpfreaks.com/topic/261036-percentage-between-two-numbers/
Share on other sites

  • 1 month later...
  • 2 months later...

Math works the same way here as it does on paper...technically in this case you don't even need to wrap anything in parens (though I usually do for better readability)...order of operations will have the division happen first...

 

You are correct.

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.