Reputation: 379
I have a table Main_exam. and fields are mark(int) ,percentage(int) and rank (int)
Iam insert mark percentage and rank to table but my problem is when im calculate my percentage value
is this maxmark=150,obtainted mark=110
% = 110 *100/150 = 73.3333333
but I want 73.33
my code is
$totalmark = $mainexamreport->sum('mainexam_mark');
$percentagemark = $totalmark*100/$fullmark->sum('maxmark');
how to change my code? I want only correct exact value not rounded value.
Upvotes: 2
Views: 5983
Reputation: 193
You can just use number_format of PHP
echo number_format($percentagemark,2);
Upvotes: 1