If an Int is bigger than 1000, how would you go about displaying it as a currency?
1500 as an example, needs to be 1.500,00
So anything above 1000 needs to have a dot and a comma followed by 2 zero's, what's a proper way to do this?
If an Int is bigger than 1000, how would you go about displaying it as a currency?
1500 as an example, needs to be 1.500,00
So anything above 1000 needs to have a dot and a comma followed by 2 zero's, what's a proper way to do this?
That's easy with the built-in php function number_format
:
The first argument is the number, the second is how many decimals you'd like to have, then the seperator between the decimals and the number and then the thousand seperator.
Example:
$formattedNumber = number_format(1234, 2, ',', '.'); // => 1.234,00
More information: https://secure.php.net/manual/en/function.number-format.php