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 element | Description |
---|---|
decimal_point | Decimal point character |
thousands_sep | Thousands separator |
int_curr_symbol | International currency symbol (example: USD) |
currency_symbol | Local currency symbol (example: $) |
mon_decimal_point | Monetary decimal point character |
mon_thousands_sep | Monetary thousands separator |
positive_sign | Sign for positive values |
negative_sign | Sign for negative values |
int_frac_digits | International fractional digits |
frac_digits | Local fractional digits |
p_cs_precedes | true if currency_symbol precedes a positive value, false if it succeeds one |
p_sep_by_space | true if a space separates currency_symbol from a positive value, false otherwise |
n_cs_precedes | true if currency_symbol precedes a negative value, false if it succeeds one |
n_sep_by_space | true if a space separates currency_symbol from a negative value, false otherwise |
p_sign_posn |
|
n_sign_posn |
|
grouping | Array containing numeric groupings (example: 3 indicates 1 000 000) |
mon_grouping | Array 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