Naffyz Mir
Naffyz Mir

Reputation: 1

Limit decimals to three digits laravel

Previous Code

$product->selling_price

Result 1.1000

I tried

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

1

I want 1.100 (for Kuwait dinar)

Upvotes: 0

Views: 1473

Answers (2)

Rajib Bin Alam
Rajib Bin Alam

Reputation: 389

Try This One: I have solved using this:

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

Upvotes: 0

John Lobo
John Lobo

Reputation: 15319

You can use number_format

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

PHP official documentation

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

Formats a number with grouped thousands and optionally decimal digits.

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

Upvotes: 1

Related Questions