Jump to content

function money_format() : space missing from currency symbols


Rick Deckard

Recommended Posts

I'm currently studying for the PHP certification and while working through study guide I noticed that the money_format() function appears to work in an inconsistent manner on my linux box. I want to report a bug but I'm not sure if this a problem with my installation or PHP. I've searched the official bug list for reports related to the function - there are 10 listed, but none related to this problem.

 

O/S - Linux (Ubuntu 8.04)

PHP Version - 5.4.2-2ubuntu5.1

 

I created this code to demonstrate the problem (hopefully):

 

$number = 100000.698 ;

$arrCountry = array ('GB', 'US', 'CA', 'AU') ;

foreach ($arrCountry as $currCountry) {

    $locale = 'en_' . $currCountry . '.UTF-8';
    setlocale (LC_MONETARY, $locale);
    	
    $locale_info = localeconv();
    $currency = $locale_info['int_curr_symbol'];
    
    $amount = money_format('%i', $number);
         
    printf ("%s [%s] %s \n",$locale, $currency, $amount);
}

 

This is the output:

 

en_GB.UTF-8 [GBP ] GBP100,000.70 
en_US.UTF-8 [uSD ] USD 100,000.70 
en_CA.UTF-8 [CAD ] CAD100,000.70 
en_AU.UTF-8 [AUD ] AUD100,000.70 

 

I would expect GBP, CAD and AUD to be formatted the same as USD - i.e. a space between the currency symbol and the numeric.

 

I was wondering if anyone had 5 minutes just to see if they get the same results on a different o/s and/or php version? It's easy to work round but I just wanted to "do the right thing" and report it as a bug if necessary - whether it be with Ubuntu or PHP.

 

Thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.