Page 1 of 1
Simple formatting issue
Posted: Tue May 03, 2011 10:36 am
by simonmlewis
[text]41123531[/text]
How do I convert this result from a variable on-the-fly, into this:
[text]41,123,531[/text]
??
I don't know what you call the change to know how find it in php sites. I'm sure it's easy, but I don't have a clue. Thanks in advance.
Re: Simple formatting issue
Posted: Tue May 03, 2011 11:17 am
by social_experiment
implode() can create that type of formatting but the original variable needs to been an array, the "glue" will then be used between each element.
Re: Simple formatting issue
Posted: Tue May 03, 2011 1:11 pm
by oscardog
social_experiment wrote:implode() can create that type of formatting but the original variable needs to been an array, the "glue" will then be used between each element.
You're making hard work for yourself, there is already a function that does what he requires;
number_format.
Re: Simple formatting issue
Posted: Wed May 04, 2011 6:36 am
by eivind
To really give it to you for free:
Code: Select all
echo number_format(41123531,0,".",",")
Re: Simple formatting issue
Posted: Wed May 04, 2011 8:23 am
by simonmlewis
luuuuvly. i knew there would be an inbuilt way.