在视图中进行除法和乘法-Laravel [英] Dividing and Multiplying in views - laravel
本文介绍了在视图中进行除法和乘法-Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在以下html模板中,我试图以以下形式获取百分比:
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>
推荐答案
您必须在方括号内进行计算:
You must do the calculation inside the brackets:
{{ number_format($i->count / $total * 100, 2) }}%
这篇关于在视图中进行除法和乘法-Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文