Hello folks! welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we are going to be studying about the PHP localeconv() Function.
The built-in PHP localeconv() function gets the numeric formatting information.
The built-in PHP localeconv() function gets the numeric formatting information.
Syntax
Following below is the syntax to use this function -
array localeconv ( void )
Parameter Details
This function does not have any parameter.
Return Value
This PHP function returns data based upon the current locale as set by setlocale(). The associative array that is returned contains the following fields -
Array Elements | Description |
---|---|
decimal_point | It represents the decimal point character. |
thousand_sep | It represents the thousands separator. |
grouping | Array containing numeric groupings. Array displays how numbers are grouped. E.g., 1 000 000 |
int_curr_symbol | It is International Currency Symbol, i.e., USD |
currency_symbol | It is local currency symbol, i.e., $ |
mon_decimal_point | It represents the Monetary decimal point character |
mon_thousands_sep | It represents the Monetary thousands separator |
Mon_grouping | Array containing monetary grouping. Array displays how monetary numbers are grouped. E.g., 1 00 00 00 |
positive_sign | It is the sign for the positive value. |
negative_sign | It is the sign for the negative value. |
int_frac_digits | It is the International fractional digits. |
frac_digits | It is local fractional digits |
p_cs_precedes | It will be TRUE (1) if currency_symbol precedes a positive value and FALSE (0) if it succeeds one. |
n_cs_precedes | It will be TRUE (1) if currency_symbol precedes a negative value and FALSE (0) if it succeeds one. |
P_sep_by_space | It will be TRUE (1) if a space separates currency_symbol from a positive value, otherwise it will be FALSE (0). |
n_sep_by_space | It will be TRUE (1) if a space separates currency_symbol from a negative value, otherwise it will be FALSE (0). |
p_sign_posn | 0 - Parentheses surrounds the quantity and currency_symbol. 1 - The + sign string precedes the currency symbol and quantity. 2- The + sign string succeeds the quantities 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 surrounds the quantity and currency_symbol. 1 - The - sign string precedes the currency symbol and quantity. 2 - The - sign string succeeds the quantities and currency_symbol. 3 - The - sign string immediately precedes the currency symbol. 4 - The - sign string immediately succeeds the currency symbol. |
Example
Try out the example below -
<?php setlocale(LC_ALL,"US"); $locale_info = localeconv(); print_r($locale_info); ?>
Output
When the above code is executed, it will produce the following result -
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 ( ) )
READ: PHP | lcfirst() Function
Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we will be studying about the PHP ltrim() Function.
Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.
Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.