PHP Function Reference

PHP localeconv() Function



The PHP localeconv() function returns an associative array containing localized numeric and monetary formatting information.

Syntax

localeconv()

Parameters

No parameter is required.

Return Value

Returns data based upon the current locale as set by setlocale(). The associative array that is returned contains the following fields:

Array elementDescription
decimal_pointDecimal point character
thousands_sepThousands separator
int_curr_symbolInternational currency symbol (example: USD)
currency_symbolLocal currency symbol (example: $)
mon_decimal_pointMonetary decimal point character
mon_thousands_sepMonetary thousands separator
positive_signSign for positive values
negative_signSign for negative values
int_frac_digitsInternational fractional digits
frac_digitsLocal fractional digits
p_cs_precedestrue if currency_symbol precedes a positive value, false if it succeeds one
p_sep_by_spacetrue if a space separates currency_symbol from a positive value, false otherwise
n_cs_precedestrue if currency_symbol precedes a negative value, false if it succeeds one
n_sep_by_spacetrue if a space separates currency_symbol from a negative value, false otherwise
p_sign_posn
  • 0 - Parentheses surround the quantity and currency_symbol
  • 1 - The sign string precedes the quantity and currency_symbol
  • 2 - The sign string succeeds the quantity and currency_symbol
  • 3 - The sign string immediately precedes the currency_symbol
  • 4 - The sign string immediately succeeds the currency_symbol
n_sign_posn
  • 0 - Parentheses surround the quantity and currency_symbol
  • 1 - The sign string precedes the quantity and currency_symbol
  • 2 - The sign string succeeds the quantity and currency_symbol
  • 3 - The sign string immediately precedes the currency_symbol
  • 4 - The sign string immediately succeeds the currency_symbol
groupingArray containing numeric groupings (example: 3 indicates 1 000 000)
mon_groupingArray containing monetary groupings (example: 2 indicates 1 00 00 00)

Example:

The example below shows the usage of localeconv() function.

<?php
setlocale(LC_ALL,"US");
$locale_info = localeconv();
print_r($locale_info);
?>

The output of the above code will be:

Array
(
    [decimal_point] => .
    [thousands_sep] => 
    [int_curr_symbol] => 
    [currency_symbol] => 
    [mon_decimal_point] => 
    [mon_thousands_sep] => 
    [positive_sign] => 
    [negative_sign] => 
    [int_frac_digits] => 127
    [frac_digits] => 127
    [p_cs_precedes] => 127
    [p_sep_by_space] => 127
    [n_cs_precedes] => 127
    [n_sep_by_space] => 127
    [p_sign_posn] => 127
    [n_sign_posn] => 127
    [grouping] => Array
        (
        )

    [mon_grouping] => Array
        (
        )

)

❮ PHP String Reference