The usage of localeconv() function in PHP

Time:2020-5-19

PHP localeconv() function

example

To find us local number formatting information:


<?php setlocale(LC_ALL,"US"); $locale_info = localeconv();
print_r($locale_info); ?>

Definition and Usage

localeconv()Function returns an array containing information about the local number and currency format.

The localeconv() function returns the following array elements:

[decimal point] – decimal character

[thousands_ SEP] – thousand separator

[int_curr_symbol] – currency symbol (for example: USD)

[currency_symbol] – currency symbol (for example: $)

[mon_ decimal_ Point] – currency decimal character

[mon? Thousands? SEP] – currency thousands separator

[positive sign] – positive character

[negative sign] – negative character

[int? Frac? Digits] – International decimal places

[frac_digits] – local common decimal places

[P ﹤ CS ﹤ precedes] – true (1) if the currency symbol is displayed before a positive value, false (0) if it is displayed after a positive value

[p_ sep_ By_ Space] – true (1) if there is a space between the currency symbol and a positive value, otherwise false (0)

[n_ Cs_ Precedes] – true (1) if the currency symbol appears before a negative value, false (0) if it appears after a negative value

[n_ sep_ By_ Space] – true (1) if there is a space between the currency symbol and a negative value, false (0) otherwise

[p_sign_post] – format options:

  • 0 – write quantity and currency symbols in parentheses
  • 1 – precede quantity and currency symbols with a + sign
  • 2 – add + after quantity and currency symbols
  • 3 – directly precede the currency symbol with a + sign
  • 4 – directly followed by a + sign

[n_sign_post] – format options:

  • 0 – write quantity and currency symbols in parentheses
  • 1 – precede quantity and currency symbols with a – sign
  • 2 – after quantity and currency symbols, add – sign
  • 3 – directly precede the currency symbol with a – sign
  • 4 – directly followed by a – sign

[grouping] – display the array in the form of number combination (for example: 3 indicates 1 000 000)

[mon_grouping] – display the array in the form of currency number combination (for example: 2 indicates 1 00 00)

Tip: to define local settings, checksetlocale() Function.

grammar

localeconv()

summary

The above is the whole content of this article. I hope that the content of this article has some reference learning value for your study or work. Thank you for your support for developepaer. If you want to know more about it, please check the relevant links below