Number format hepp needed.

Discussion in 'PHP' started by KingCobra, Dec 13, 2009.

  1. #1
    $number01 = 5000 and 5000.5 and 5000.507
    I want to show this like 5000.00 and 5000.50 and 5000.51

    $number02 = 25500000;
    I want to show this like 2,55,00,000.00


    PLEASE HELP
     
    KingCobra, Dec 13, 2009 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    echo number_format($number, 2);
    PHP:
     
    JAY6390, Dec 13, 2009 IP
  3. Wogan

    Wogan Peon

    Messages:
    81
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    0
    #3
    Wow, your $number02 request is complicated. number_format() lets you choose decimal place, decimal seperator and thousands seperator, but nothing that'll give you , after every 2 digits. If you really need that, you're looking at looping through the number to put commas in place.
     
    Wogan, Dec 13, 2009 IP