How to check how many characters in variable, and add space between characters in that var?
Posted
by Camran
on Stack Overflow
See other posts from Stack Overflow
or by Camran
Published on 2009-11-02T15:46:47Z
Indexed on
2010/04/07
10:53 UTC
Read the original article
Hit count: 148
I have a 'price' variable that contains some integer number from a MySQL database.
I want to check how many numbers the 'price' variable contains, and add a space in the variable depending on how many numbers. See below:
Example:
If 'price' is 150000 I would like the output to be 150 000 (notice the space). OR, if it is 19000 I would like it to output 19 000...
How would you do this the easiest way?
© Stack Overflow or respective owner