PHP localeconv()Functions

PHP String 参考手册PHP String Reference Manual

Examples

Find the numeric formatting information for the US locale:

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

Run example »

Definition and Usage

The localeconv() function returns an array containing local numeric and currency formatting information.

The localeconv() function returns the following array elements:

  • [decimal_point] - Decimal point character
  • [thousands_sep] - Thousands separator
  • [int_curr_symbol] - International currency symbol (e.g., USD)
  • [currency_symbol] - Currency symbol (e.g., $)
  • [mon_decimal_point] - Monetary decimal point character
  • [mon_thousands_sep] - Monetary thousands separator
  • [positive_sign] - Positive sign character
  • [negative_sign] - Negative sign character
  • [int_frac_digits] - International fractional digits
  • [frac_digits] - Local fractional digits
  • [p_cs_precedes] - True (1) if the currency symbol is displayed before a positive value, False (0) if it is displayed after the 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 is displayed before a negative value, False (0) if it is displayed after the negative value
  • [n_sep_by_space] - True (1) if there is a space between the currency symbol and a negative value, otherwise False (0)
  • [p_sign_posn] - Formatting options:
    • 0 - Put the amount and currency symbol in parentheses
    • 1 - Add a + sign before the amount and currency symbol
    • 2 - Add a + sign after the amount and currency symbol
    • 3 - Add a + sign directly before the currency symbol
    • 4 - Add a + sign directly after the currency symbol
  • [n_sign_posn] - Formatting options:
    • 0 - Put the amount and currency symbol in parentheses
    • 1 - Add a - sign before the amount and currency symbol
    • 2 - Add a - sign after the amount and currency symbol
    • 3 - Add a - sign directly before the currency symbol
    • 4 - Add a - sign directly after the currency symbol
  • [grouping] - An array showing how numbers are grouped (e.g., 3 indicates 1 000 000)
  • [mon_grouping] - An array showing how monetary numbers are grouped (e.g., 2 indicates 1 00 00 00)

Tip:To define local settings, please see thesetlocale()function.

Tip:To view all available language codes, please visit ourLanguage Code Reference Manual。


Syntax

localeconv()

Technical Details

Return value: Returns data for the current locale based on the setlocale() setting.
PHP Version: 4.0.5+


PHP String 参考手册PHP String Reference Manual Other Extensions