mirror of
https://github.com/archtechx/money.git
synced 2025-12-12 19:34:02 +00:00
Remove trailing zeros from formatted price
This commit is contained in:
parent
545610efb0
commit
b7093f4f05
1 changed files with 6 additions and 0 deletions
|
|
@ -23,6 +23,12 @@ class PriceFormatter
|
||||||
$currency->thousandsSeparator(),
|
$currency->thousandsSeparator(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Remove trailing zeros from price
|
||||||
|
$decimal = rtrim($decimal, '0');
|
||||||
|
// If there is no more decimal values, remove the trailing decimal separator as well
|
||||||
|
$decimal = rtrim($decimal, $currency->decimalSeparator());
|
||||||
|
|
||||||
|
|
||||||
return $currency->prefix() . $decimal . $currency->suffix();
|
return $currency->prefix() . $decimal . $currency->suffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue