Hi. 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 %.
Hi. 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 %.
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,'.').' %';
?>
Too many possible ways, here is another one:
<?php
echo sprintf( "%d %%", ( $total / $win ) * 100 );
?>