Dan's Website

Ramblings of a Disaffected Geek

 
Home > Software > Currency formatting in PHP
Currency formatting in PHP
Gets currency formatting correct for your location.

setlocale(LC_ALL, 'en_AU');

print_r(localeconv());

print money_format("%n", 12345)."\n";

print money_format("%i", 12345)."\n";
 

Outputs the following:

 

Array

(

    [decimal_point] => .

    [thousands_sep] => ,

    [int_curr_symbol] => AUD 

    [currency_symbol] => $

    [mon_decimal_point] => .

    [mon_thousands_sep] => ,

    [positive_sign] => 

    [negative_sign] => -

    [int_frac_digits] => 2

    [frac_digits] => 2

    [p_cs_precedes] => 1

    [p_sep_by_space] => 0

    [n_cs_precedes] => 1

    [n_sep_by_space] => 0

    [p_sign_posn] => 1

    [n_sign_posn] => 1

    [grouping] => Array

        (

            [0] => 3

            [1] => 3

        )

 

    [mon_grouping] => Array

        (

            [0] => 3

            [1] => 3

        )

 

)

$12,345.00

AUD12,345.00

 

 

 
Comments
Add New Search
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.23 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."