Jump to content

[SOLVED] Getting a percentage


timmah1

Recommended Posts

I'm trying to get 10% of a number.

 

I am doing this

$number = $row1['total'] * .10;

 

But, the number is showing a decimal

 

If I have the number 328,194.00

10% is this 32,819.40

it is showing me 32819.4

 

but I only need it to show  3281940

 

How do I do I get the decimal out of the percentage?

 

Thanks in advance

 

 

Link to comment
https://forums.phpfreaks.com/topic/113944-solved-getting-a-percentage/
Share on other sites

10% of 328,194.00 would be 32,819.4, not 3,281,940.00 so I am confused about what you want.

 

You can use the function round() to round the number or floor() to truncate at the decimal. Or even number_format() to change the number of decimals returned:

http://www.php.net/manual/en/function.round.php

http://www.php.net/manual/en/function.floor.php

http://www.php.net/manual/en/function.number-format.php

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.