We now have a youtube channel. Subscribe!

PHP | localeconv() Function

PHP localeconv() Function


Hello folks! welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we are going to be studying about the PHP localeconv() Function.

The built-in PHP localeconv() function gets the numeric formatting information.

Syntax

Following below is the syntax to use this function -

array localeconv ( void )


Parameter Details

This function does not have any parameter.

Return Value

This PHP function returns data based upon the current locale as set by setlocale(). The associative array that is returned contains the following fields -

Array ElementsDescription
decimal_pointIt represents the decimal point character.
thousand_sepIt represents the thousands separator.
groupingArray containing numeric groupings. Array displays how numbers are grouped. E.g., 1 000 000
int_curr_symbolIt is International Currency Symbol, i.e., USD
currency_symbolIt is local currency symbol, i.e., $
mon_decimal_pointIt represents the Monetary decimal point character
mon_thousands_sepIt represents the Monetary thousands separator
Mon_groupingArray containing monetary grouping. Array displays how monetary numbers are grouped. E.g., 1 00 00 00
positive_signIt is the sign for the positive value.
negative_signIt is the sign for the negative value.
int_frac_digitsIt is the International fractional digits.
frac_digitsIt is local fractional digits
p_cs_precedesIt will be TRUE (1) if currency_symbol precedes a positive value and FALSE (0) if it succeeds one.
n_cs_precedesIt will be TRUE (1) if currency_symbol precedes a negative value and FALSE (0) if it succeeds one.
P_sep_by_spaceIt will be TRUE (1) if a space separates currency_symbol from a positive value, otherwise it will be FALSE (0).
n_sep_by_spaceIt will be TRUE (1) if a space separates currency_symbol from a negative value, otherwise it will be FALSE (0).
p_sign_posn0 - Parentheses surrounds the quantity and currency_symbol.
1 - The + sign string precedes the currency symbol and quantity.
2- The + sign string succeeds the quantities and currency_symbol.
3 - The + sign string immediately precedes the currency symbol.
4 - The + sign string immediately succeeds the currency symbol.
n_sign_posn0 - Parentheses surrounds the quantity and currency_symbol.
1 - The - sign string precedes the currency symbol and quantity.
2 - The - sign string succeeds the quantities and currency_symbol.
3 - The - sign string immediately precedes the currency symbol.
4 - The - sign string immediately succeeds the currency symbol.

Example

Try out the example below -

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

Output

When the above code is executed, it will produce the following 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 ( ) )


Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we will be studying about the PHP ltrim() Function.

Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.

Post a Comment

Hello dear readers! Please kindly try your best to make sure your comments comply with our comment policy guidelines. You can visit our comment policy page to view these guidelines which are clearly stated. Thank you.
© 2023 ‧ WebDesignTutorialz. All rights reserved. Developed by Jago Desain