我是 Laravel 和 Blade 模板方面的新手。
谁能帮我看看怎么做?
我的观点是这样的:
@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)
但它没有用。
最佳答案
这应该有效:
<td>{{ number_format($Expense->price, 2) }}</td>
关于php - 在 Laravel 中使用 number_format 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27651808/