I have a price, let's say $price = 9,00 €
. If price have 2 zeroes after comma is there easy way to transform it to 9 €
? I mean is there a function for that or something. If that is not possible with €
character, how to do that only with integers 9,00
> 9
, but 9,20
would stay 9,20
.
I know it could be done with substr
or some other ways, but I'd like to know if PHP have function for this situation.
You have to use NumberFormatter.
parse it to float
check if is int or float
reformat