Author Topic: Integer formatting  (Read 712 times)

Offline Wakish

  • Level 14
  • *
  • Posts: 111
  • Reputation: +0/-1
    • View Profile
    • Wakish Wonderz
Integer formatting
« on: January 29, 2008, 03:39:41 AM »
Is there a way of formatting something like 2222222222 to 2,222,222,222 ? (in php of course)
So whatever the length of the integer, it should be able to display it in that fashion.
I search for it, but found in this style 2,222.22 which I don't like..

Any suggestion please?
« Last Edit: January 29, 2008, 03:44:46 AM by wakish »

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Integer formatting
« Reply #1 on: January 29, 2008, 04:56:07 AM »
http://nl3.php.net/manual/en/function.number-format.php

You can choose the settings for formatting the numbers.

Offline Wakish

  • Level 14
  • *
  • Posts: 111
  • Reputation: +0/-1
    • View Profile
    • Wakish Wonderz
Re: Integer formatting
« Reply #2 on: January 29, 2008, 11:13:50 AM »
http://nl3.php.net/manual/en/function.number-format.php

You can choose the settings for formatting the numbers.


Cool.. Thanks Zeg!

This one seems to work for me:
Quote
$val = "1000000";
echo number_format($val, 0, "", ","); // returns 1,000,000

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal