I have a full int
value already with the decimals and I want to convert like this in PHP
500 -> 5,00$
5070 -> 50,70$
50070 -> 500,70$
500000 -> 5.000,00$
so the format should be like this xxx.xxx.xxx.xxx,xx$
any function for that?
number_format() can do the job.
It works like this : string number_format(float $number, int $decimals = 0, string $dec_point = ".", string $thousands_sep = ",")
number
The number being formatted.
decimals
Sets the number of decimal points.
dec_point
Sets the separator for the decimal point.
thousands_sep
Sets the thousands separator.
In your case, that could be $myMoney = number_format($cents / 100, 2, ",", ".") . "$";