PHP String localeconv() FunctionThe localeconv() function is the in-built function of PHP. It is used to get numeric information. This function returns an array which contains local numeric and monetary formatting information. This function is a non-parameterized function, so we do not need to pass anything in this function. SyntaxThe basic syntax of the localeconv() function of PHP is: ParameterNo parameter is required in localeconv() function. Value returned by localeconv()This function returns the data based upon the current locale, which is set by setlocale() function. An associative array is returned which contains the following fields:
Note: The p_sign_posn and n_sign_posn contain a string of formatting options, and each number represents one of the above-listed condition.ExampleBelow some examples are given to understand the localeconv() function in a much better way: Example 1Output: The above output will be shown like this in view source. 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 ) ) Example 2Output: Below is the view source of the above program. With the help of this output representation, we can easily see the difference among different examples. 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 ) ) Example 3Output: 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 ( [0] => 3 ) [mon_grouping] => Array ( ) ) Example 4Output: 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 ( ) ) Here, you can see the changes in each and every output of the example. Note: To understand the working of setlocale() function follow the given link https://www.javatpoint.com/php-string-setlocale-function.Next TopicPHP String Functions |