SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Earth
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems with money_format or setlocale

    I have an value that I grabbed from a database that I want to convert to US money format. On my test server (PHP 4.3.3) I have the following:

    setlocale(LC_ALL, 'en_US');
    $value= money_format('%(.0n', $value);

    The output is like this: $180,000

    But when I upload the script to the production server (PHP 4.3.8), the output looks like all numbers, no formating: 180000

    Does someone have any idea what's going on?

  2. #2
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,524
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From the manual:
    money_format() returns a formatted version of number. This function wraps the C library function strfmon(), with the difference that this implementation converts only one number at a time.

    Note: The function money_format() is only defined if the system has strfmon capabilities. For example, Windows does not, so money_format() is undefined in Windows.
    Don't know if that helps. There's actually way more on money_format than what I quoted. Go read the rest of what it says. Perhaps you'll find something that will help answer why this isn't working in production for you.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web

  3. #3
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Earth
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    *SOLVED* Problems with money_format or setlocale

    That did it, thanks!

  4. #4
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Earth
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, I actually responded to the wrong forum. This is the solution:

    Note: The function money_format() is only defined if the system has strfmon capabilities. For example, Windows does not, so money_format() is undefined in Windows.

    Code:
    $m = 180000;
    echo '$' . number_format($m, 0);


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •