PHP localeconv() function

Example

Find the local number formatting information in the United States:

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

Running Instance

Definition and Usage

The localeconv() function returns an array containing local number and currency format information.

The localeconv() function returns the following array elements:

  • [decimal_point] - Decimal point character
  • [thousands_sep] - Thousands separator
  • [int_curr_symbol] - Currency symbol (e.g., USD)
  • [currency_symbol] - Currency symbol (e.g., $)
  • [mon_decimal_point] - Currency decimal point character
  • [mon_thousands_sep] - Currency thousands separator
  • [positive_sign] - Character for positive values
  • [negative_sign] - Character for negative values
  • [int_frac_digits] - International decimal places for general use
  • [frac_digits] - Local decimal places for general use
  • [p_cs_precedes] - True (1) if the currency symbol is displayed before the positive value, otherwise False (0)
  • [p_sep_by_space] - True (1) if there is a space between the currency symbol and the positive value, otherwise False (0)
  • [n_cs_precedes] - True (1) if the currency symbol is displayed before a negative value, otherwise False (0)
  • [n_sep_by_space] - True (1) if there is a space between the currency symbol and the negative value, otherwise False (0)
  • [p_sign_posn] - Formatting Options:
    • 0 - Write the quantity and currency symbol within parentheses
    • 1 - Add a plus sign before the quantity and currency symbol
    • 2 - Add a plus sign after the quantity and currency symbol
    • 3 - Add a plus sign directly before the currency symbol
    • 4 - Add a plus sign directly after the currency symbol
  • [n_sign_posn] - Formatting Options:
    • 0 - Write the quantity and currency symbol within parentheses
    • 1 - Add a hyphen before the quantity and currency symbol
    • 2 - Add a hyphen after the quantity and currency symbol
    • 3 - Add a hyphen directly before the currency symbol
    • 4 - Add a hyphen directly after the currency symbol
  • [grouping] - Display the array of number grouping forms (e.g., 3 indicates 1 000 000)
  • [mon_grouping] - Display the array of currency number grouping forms (e.g., 2 indicates 1 00 00 00)

Tip:To define the locale settings, please refer to setlocale() Functions.

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

Syntax

localeconv()

Technical Details

Return Value: Returns data based on the current locale set by setlocale().
PHP Version: 4.0.5+