Simple question. I have this code:
total = 41
win   = 48
       echo ($total/$win) * 100 ; 
printing out
85.416666666667
I need to remove the开发者_开发技巧 remainder so it prints out: 85 %.
http://www.ideone.com/7JFkI
echo floor(($total/$win) * 100) . '%';
Depending on how to want to round the number you may need to replace floor() with one of
- floor()(9.4 → 9, 9.7 → 9)
- round()(9.4 → 9, 9.7 → 10)
- ceil()(9.4 → 10, 9.7 → 10)
Use the round(); function.
<?php
$total = 41;
$win   = 48;
echo round(($total/$win)*100).' %'; 
?>
the elegant way would be to use string
number_format(float $number, int $decimals, string $dec_point, string $thousands_sep);
like this:
<?php
$total = 41;
$win   = 48;
echo number_format(($total/$win)*100,0,'.').' %'; 
?>
You can use the floor function:
echo floor(($total/$win) * 100) ; 
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论