Reputation: 571
How can I format floats by sprintf
like I would do by number_format()
?
I need
With number_format()
I would do so
$number = number_format(1599, 0, ".", ",");
The result should be:
1599 => 1.500
899.99 => 899
70 => 70
Is this possible using sprintf()
?
Kind regards, Robert
Upvotes: 11
Views: 12451
Reputation: 522219
sprintf('A number: %s', number_format(1599, 0, '.', ','))
No, there is no other way. (s)printf
doesn't have options for adding thousand separators.
Upvotes: 18