Reputation: 45
In the following html template, I am trying to get the percentage, in the form:
4%
but when I perform multiplication and division, it appears as
2/50*100
How can I get my desired result?
<div class="card-content collapse show">
<div class="card-body">
@foreach ($items->products as $i)
<div style="font-size:14px">{{$i->count}}/{{$total}}*100 %</div>
@endforeach
</div>
</div>
Upvotes: 1
Views: 6387
Reputation: 24276
You must do the calculation inside the brackets:
{{ number_format($i->count / $total * 100, 2) }}%
Upvotes: 7