Reputation: 3
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?
Upvotes: 0
Views: 389
Reputation: 360602
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)
Upvotes: 4