How to obtain the corresponding LOCALE information through the CURRENCY symbol "CURRENCY.

Source: Internet
Author: User
The cause of this problem is as follows: there is an international recharge business, and the information is as follows: {code ...} among them, money is the recharge amount (the current locale amount), and currency is the currency information corresponding to money. For the convenience of accounting statistics, I want to convert money between 48.00 into a visible floating point... the cause of this problem is as follows:

There is an international recharge business, the information is as follows:

MONEY:₱48.00 CURRENCY:PHP

Among them, money is the recharge amount (the current locale amount), and currency is the currency information corresponding to money.

For the convenience of accounting statistics, I want to take money₱48.00Converts it to a floating point information that is recognized by the naked eye.

So with the help of PHP officialintlThe extension code is developed as follows:

$ Locale =? $ Money = 'prop 48.00 '; $ currency = 'php'; $ fmt = new NumberFormatter ($ locale, NumberFormatter: CURRENCY ); $ __= $ fmt-> parseCurrency ($ money, $ currency); var_dump ($ __) // $ __== false indicates a conversion failure. if it is float, the conversion is successful.

UnexpectedlocaleInformation cannot be obtained.intlMediumlocaleTo obtain the following information:

$locale = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);var_dump($locale);

However, accept_language is not a normal locale information.

So is there a way to passcurrencyObtainedlocale

Reply content:

The cause is as follows:

There is an international recharge business, the information is as follows:

MONEY:₱48.00 CURRENCY:PHP

Among them, money is the recharge amount (the current locale amount), and currency is the currency information corresponding to money.

For the convenience of accounting statistics, I want to take money₱48.00Converts it to a floating point information that is recognized by the naked eye.

So with the help of PHP officialintlThe extension code is developed as follows:

$ Locale =? $ Money = 'prop 48.00 '; $ currency = 'php'; $ fmt = new NumberFormatter ($ locale, NumberFormatter: CURRENCY ); $ __= $ fmt-> parseCurrency ($ money, $ currency); var_dump ($ __) // $ __== false indicates a conversion failure. if it is float, the conversion is successful.

UnexpectedlocaleInformation cannot be obtained.intlMediumlocaleTo obtain the following information:

$locale = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);var_dump($locale);

However, accept_language is not a normal locale information.

So is there a way to passcurrencyObtainedlocale

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.