How to use localeconv in PHP

In this article I will explain how the localeconv() function can be used in PHP.
  • 1309

localeconv() function in PHP

The localeconv() function is used to return an array containing local numeric and monetary formatting information.

The localeconv() function will return the following array elements:

  • [decimal_point] - it's represent decimal point character.
  • [thousands_sep] - it's represent thousands separator.
  • [int_curr_symbol] - it's represent currency symbol.
  • [currency_symbol] - it's represent currency symbol.
  • [mon_decimal_point] - it's represent monetary decimal point character.
  • [mon_thousands_sep] - it's represent monetary thousands separator.
  • [positive_sign] - it's represent positive value character.
  • [negative_sign] - it's represent negative value character.
  • [int_frac_digits] - it's represent international fractional digits.
  • [frac_digits] - it's represent local fractional digits.
  • [p_cs_precedes] - True (1) if currency symbol is placed in front of a positive value, False (0) if it is placed behind.
  • [p_sep_by_space] - True (1) if there is a spaces between the currency symbol and a positive value, False (0) otherwise.
  • [n_cs_precedes] - True (1) if currency symbol is placed in front of a negative value, False (0) if it is placed behind.
  • [n_sep_by_space] - True (1) if there is a spaces between the currency symbol and a negative value, False (0) otherwise.
  • [p_sign_posn] - Formatting options:
    • 0 - Parentheses surround the quantity and currency symbol.
    • 1 - The + sign is placed in front of the quantity and currency symbol.
    • 2 - The + sign is placed after the quantity and currency symbol.
    • 3 - The + sign is placed immediately in front of the currency symbol.
    • 4 - The + sign is placed immediately after the currency symbol.
  • [n_sign_posn] - Formatting options:
    • 0 - Parentheses surround the quantity and currency symbol.
    • 1 - The - sign is placed in front of the quantity and currency symbol.
    • 2 - The - sign is placed after the quantity and currency symbol.
    • 3 - The - sign is placed immediately in front of the currency symbol.
    • 4 - The - sign is placed immediately after the currency symbol.
  • [grouping] - Array displaying how numbers are grouped.
  • [mon_grouping] - Array displaying how monetary numbers are grouped.

Syntax

localeconv()

Example

The following example show to how the localeconv() function can be used in PHP.

<html>

<body>

<h3 style="color: yellowgreen;">localeconv() function example in PHP</h3>

    <?php

    setlocale(LC_ALL, 'US');

    $locale_info = localeconv();

    print_r($locale_info);

    ?>

</body>

</html>

 

Output

localeconv-php.gif
You may also want to read these related articles here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.