簡體   English   中英

將小數限制為三位 laravel

[英]Limit decimals to three digits laravel

以前的代碼

$product->selling_price

結果 1.1000

我試過了

({{ ceil($product->selling_price) }})

1

我要 1.100(科威特第納爾)

您可以使用number_format

number_format((float)$product->selling_price, 3, '.')

PHP 官方文檔

number_format ( float $num, int $decimals = 0, string|null $decimal_separator = ".", string|null $thousands_separator = "," ): string

使用分組的千位和可選的十進制數字格式化數字。

參考: https://www.php.net/manual/en/function.number-format.php

試試這個:我已經解決了這個問題:

 number_format((float)$product->payable_amount, 2,)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM