我怎样才能显示最多2个小数点
How can I show up to 2 decimal points
我正在 laravel 6.20 中创建一个电子商务网站,我想在产品视图页面中显示百分比折扣。我可以显示一个整数,但我想以小数点后两位的格式显示百分比。任何帮助将不胜感激。
<ul class="product_marks">
@if($row->discount_price == NULL)
@else
<li class="product_mark product_discount">
-{{round(($row->discount_price/$row->selling_price)*100)}}%
</li>
@endif
<li class="product_mark product_new">NEW</li>
</ul>
Please check this image for reference
您可以使用number_format($number, $decimal_points)
来定义您想要的小数点位数:
-{{number_format(round(($row->discount_price/$row->selling_price)*100), 2)}}%
我正在 laravel 6.20 中创建一个电子商务网站,我想在产品视图页面中显示百分比折扣。我可以显示一个整数,但我想以小数点后两位的格式显示百分比。任何帮助将不胜感激。
<ul class="product_marks">
@if($row->discount_price == NULL)
@else
<li class="product_mark product_discount">
-{{round(($row->discount_price/$row->selling_price)*100)}}%
</li>
@endif
<li class="product_mark product_new">NEW</li>
</ul>
Please check this image for reference
您可以使用number_format($number, $decimal_points)
来定义您想要的小数点位数:
-{{number_format(round(($row->discount_price/$row->selling_price)*100), 2)}}%