English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP localeconv() function usage and example

   PHP String String Functions Manual

    The localeconv() function is used to get the array of numerical and currency formatting information.

Syntax

array localeconv ( void )

Definition and usage

Used to get the array of number format information

The localeconv() function returns the following array elements:

  • [decimal_point] - Decimal point character

  • [thousands_sep] - Thousand separator

  • [int_curr_symbol] - Currency symbol (for example: USD)

  • [currency_symbol] - Currency symbol (for example: $)

  • [mon_decimal_point] - Currency decimal point character

  • [mon_thousands_sep] - Currency thousand separator

  • [positive_sign] - Positive value character

  • [negative_sign] - Negative value character

  • [int_frac_digits] - International general decimal places

  • [frac_digits] - Local general decimal places

  • [p_cs_precedes] - If the currency symbol is displayed before a positive value, it is True(1), if displayed after the positive value, it is False

  • [p_sep_by_space] - If there is a space between the currency symbol and the positive value, it is True(1), otherwise False

  • [n_cs_precedes] - If the currency symbol is displayed before a negative value, it is True(1), if displayed after the negative value, then False

  • [n_sep_by_space] - If there is a space between the currency symbol and the negative value, then True(1), otherwise False

  • [p_sign_posn] - Formatting Options:

    • 0 - Write the quantity and currency symbol within parentheses

    • 1 - Add before the quantity and currency symbol + Number

    • 2 - Add after the quantity and currency symbol + Number

    • 3 - Add directly before the currency symbol + Number

    • 4 - Add directly after the currency symbol + Number

  • [n_sign_posn] - Formatting Options:

    • 0 - Write the quantity and currency symbol within parentheses

    • 1 - Add before the quantity and currency symbol - Number

    • 2 - Add after the quantity and currency symbol - Number

    • 3 - Add directly before the currency symbol - Number

    • 4 - Add directly after the currency symbol - Number

  • [grouping] - Display the array of number combinations (for example:)3 Indication 1 000 000)

  • [mon_grouping] - Display the array of currency number combinations (for example:)2 Indication 1 00 00 00)

Tip:To define the local settings, please see setlocale() Function.

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

Return Value

It returns data based on the current locale set by setlocale().

Online Example

Try the following example, returning the US local number formatting information

<?php
   //Back to the US local number formatting information
   setlocale(LC_ALL, "US");
   $locale_info = localeconv();
   
   print_r($locale_info);
?>
Test and see‹/›

Output 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 ( ) )

PHP String String Functions Manual