本文介绍了在Laravel中使用number_format方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Laravel和Blade模板制作方面还很陌生.
谁能帮我看看如何做到这一点?
I am fairly new in Laravel and Blade templating.
Can anyone help show me how to do this?
我有这样的看法:
@foreach ($Expenses as $Expense)
<tr>
<td>{{{ $Expense->type }}}</td>
<td>{{{ $Expense->narration }}}</td>
<td>{{{ $Expense->price }}}</td>
<td>{{{ $Expense->quantity }}}</td>
<td>{{{ $Expense->amount }}}</td>
</tr>
@endforeach
我希望格式化$Expense->price
和$Expense->amount
.
我尝试在$Expense->amount
上将其用作number_format($Expense->amount)
,但没有用.
I want the $Expense->price
and$Expense->amount
to be formatted.
I tried using it on the $Expense->amount
as number_format($Expense->amount)
but it didn't work.
推荐答案
这应该有效:
<td>{{ number_format($Expense->price, 2) }}</td>
这篇关于在Laravel中使用number_format方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!