I know i could write a custom function that does just this, but it feels like this is such a function that should already exist (built in).
So,开发者_运维问答 i simply just want to add spaces to make it easier to read:
1200 would become: 1 200 10000 would become: 10 000 150000 would become: 150 000 etc...
Is there a function to just "pop" in a string/character into another string at a specified position?
Are you just formatting numbers? there's number_format()
which will accept any type of seperator:
$formatted = number_format(1200, 0, '.', ' '); // "1 200"
1 2 3
1. # of decimal places
2. decimal place character (not inserted, since we've specified 0 decimals)
3. thousands separator (space, in this case)
精彩评论