Συνάρτηση localeconv() PHP
Παράδειγμα
Αναζήτηση τοπικών πληροφοριών μορφοποίησης αριθμών στις Ηνωμένες Πολιτείες:
<?php setlocale(LC_ALL,"US"); $locale_info = localeconv(); print_r($locale_info); ?>
Ορισμός και χρήση
Η συνάρτηση localeconv() επιστρέφει ένα μακρό από στοιχεία που περιέχει πληροφορίες μορφοποίησης αριθμών και νομισμάτων τοπικής γλώσσας.
Η συνάρτηση localeconv() θα επιστρέψει τα στοιχεία του παρακάτω μακέτ:
- [decimal_point] - Σύμβολο δεκαδικού σημείου
- [thousands_sep] - Σημαία διαχωρισμού χιλιάδων
- [int_curr_symbol] - Σύμβολο νομίσματος (π.χ. USD)
- [currency_symbol] - Σύμβολο νομίσματος (π.χ. $)
- [mon_decimal_point] - Σύμβολο δεκαδικού σημείου νομίσματος
- [mon_thousands_sep] - Σημαία διαχωρισμού χιλιάδων νομίσματος
- [positive_sign] - Σύμβολο θετικής τιμής
- [negative_sign] - Σύμβολο αρνητικής τιμής
- [int_frac_digits] - Διεθνείς γενικές δεκαδικές ψηφίδες
- [frac_digits] - Τοπικές γενικές δεκαδικές ψηφίδες
- [p_cs_precedes] - Αν το σύμβολο νομίσματος εμφανίζεται πριν από την θετική τιμή, τότε είναι Αληθής (1), αν εμφανίζεται μετά από την θετική τιμή, τότε είναι Λάθος (0)
- [p_sep_by_space] - Αν υπάρχει κενό μεταξύ του συμβόλου νομίσματος και της θετικής τιμής, τότε είναι Αληθής (1), αλλιώς είναι Λάθος (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] - Displays an array of number grouping forms (e.g., 3 indicates 1 000 000)
- [mon_grouping] - Displays an array of currency number grouping forms (e.g., 2 indicates 1 00 00 00)
Tip:For defining 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+ |