|
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
|