PDA

View Full Version : How do I get a comma in my forum stats?


Gutspiller
09-07-2002, 05:42 PM
I want a comma to be used in my stats like instead of showing:

Registered Members: 1059

I want it to show:

Registered Members: 1,059

But I also want it to work with Total Posts, and Total Threads.

Can somebody help me? This seems simple enough, but I can't figure it out. :(

Any help would be appreciated.

Thanks.

futureal
09-07-2002, 07:39 PM
Any time a variable is being set up for output, you can format it using the PHP function number_format($var). I have a hack in the works that does this in a number of places on the site.

For example, suppose (and this is not real vBulletin code) that the total members are stored in $totalmembers. You would add a line to the code somewhere that looks like:


$totalmembers = number_format($totalmembers);


MAKE SURE that if you do this, the variable you create is only being used for output. After you call number_format(...), the resulting variable is converted to (or created as) a string.

In other words, code like this would work:


$somevar = 1050;
$somevar++;
$somevar = number_format($somevar);

// outputs 1,051
echo $somevar . "<br>";


But this code would NOT work:


$somevar = 1050;
$somevar = number_format($somevar);

// error, $somevar is now a string
$somevar++;


Hope that makes some sense. :)

Gutspiller
09-12-2002, 01:38 AM
That just prints out the code that I added. It doesn't do it and then print the outcome it prints the actual


$somevar = number_format($somevar);


How do I do it?

serhat_kk
07-30-2006, 03:58 AM
I need this too...
Please help