Created
October 28, 2015 10:00
-
-
Save khoand0000/0ba7c416bb9ec1b6461d to your computer and use it in GitHub Desktop.
money_format is not working with Vietnamese
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$number = 1234.56; | |
// let's print the international format for the en_US locale | |
setlocale(LC_MONETARY, 'en_US'); | |
echo money_format('%i', $number) . "\n"; | |
// USD 1,234.56 | |
// but if using vi_VN or vi_VN.UTF-8, not working | |
setlocale(LC_MONETARY, 'vi_VN'); | |
echo money_format('%i', $number) . "\n"; | |
// 1234.56 |
$fmt = numfmt_create( 'vi_VN', \NumberFormatter::CURRENCY );
numfmt_format_currency($fmt, $product->price, 'VND')
result:
300.000 ₫
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hope this can help:
https://www.php.net/manual/en/numberformatter.formatcurrency.php