Home >>PHP Tutorial >PHP localeconv() Function

PHP localeconv() Function

PHP localeconv() Function

PHP localeconv() function is used to get United States locale numeric formatting information. This function is a non-parameterized function, which means this function does not need any value to be pass as input. This function returns an array as result which contains local numeric and monetary formatting information.

Syntax:

 localeconv();  

Value returned by localeconv():

Array Elements Description
decimal_point Represents decimal point character.
thousand_sep Represents thousands separator.
int_curr_symbol International Currency Symbol (USD).
currency_symbol Local currency symbol ($).
mon_decimal_point Represents Monetary decimal point character.
mon_thousands_sep Represents Monetary thousands separator.
positive_sign Positive value sign.
negative_sign Negative value sign.
int_frac_digits Represents International fractional digits.
Represent Local fractional digits.

Here is an example of localeconv() function in PHP:

<html>
<body>

<?php
setlocale(LC_ALL,"US");
$locale = localeconv();
print_r($locale);
?>
 
</body>
</html>
Output:
Array
(
[decimal_point] => .
[thousands_sep] =>
[int_curr_symbol] => USD
[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] => 3
[n_sign_posn] => 0
[grouping] => Array
(
)
[mon_grouping] => Array
(
[0] => 3
)
)

Here is an another example of localeconv() function in PHP:

<html>
<body>

<?php  
    setlocale(LC_MONETARY,"US");  
    $localeinfo =localeconv();  
    print_r($localeinfo);  
?>  
 
</body>
</html>
Output:
Array
(
[decimal_point] => .
[thousands_sep] => ,
[int_curr_symbol] => USD
[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] => 3
[n_sign_posn] => 0
[grouping] => Array
(
[0] => 3
)
[mon_grouping] => Array
(
[0] => 3
)
)

Popular Tutorials