PHP localeconv() Function
Topic: PHP String ReferencePrev|Next
Description
The localeconv()
function returns an associative array containing localized numeric and monetary formatting information. The returned array contains the following elements:
Array element | Description |
---|---|
decimal_point |
Decimal point character |
thousands_sep |
Separator character for thousands |
int_curr_symbol |
International currency symbol (e.g., USD) |
currency_symbol |
Local currency symbol (e.g., $) |
mon_decimal_point |
Monetary decimal point character |
mon_thousands_sep |
Monetary thousands separator |
positive_sign |
Sign for positive values (e.g., +) |
negative_sign |
Sign for negative values (e.g., -) |
int_frac_digits |
International fractional digits |
frac_digits |
Local fractional digits |
p_cs_precedes |
true (1) if currency symbol comes before a positive value, false (0) if it comes after the value |
p_sep_by_space |
true (1) if there is a spaces between the currency symbol and a positive value, false (0) otherwise |
n_cs_precedes |
true (1) if currency symbol comes before a negative value, false (0) if it comes after the value |
n_sep_by_space |
true (1) if there is a spaces between the currency symbol and a negative value, false (0) otherwise |
p_sign_posn |
|
n_sign_posn |
|
grouping |
Array containing numeric groupings (e.g., 2 indicates 1 00 00 00) |
mon_grouping |
Array containing monetary groupings (e.g., 3 indicates 1 000 000) |
Tip: The grouping and mon_grouping fields indicates how digits in numbers and currency values should be grouped and separated by the thousands separator character. Also, see the setlocale()
function reference to understand how to define locale settings.
The following table summarizes the technical details of this function.
Return Value: | Returns data based upon the current locale as set by setlocale() . |
---|---|
Version: | PHP 4.0.5+ |
Syntax
The basic syntax of the localeconv()
function is given with:
The following example shows the localeconv()
function in action.
Example
Run this code »<?php
// Getting the United States locale numeric formatting information
if(false !== setlocale(LC_ALL, "en_US")){
$locale_info = localeconv();
print_r($locale_info);
}
?>
The output of the above example will look something like this:
Parameters
The localeconv()
function doesn't have any parameters.