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