I'm trying to use money_format
function.
<?php
$number = 1299.46;
setlocale(LC_MONETARY, 'en_US');
echo money_format('%i', $number); // Outputs 1299.46
While it should print $ sign or USD ?
I'm on linux hosting.
Thanks
Locales are constants defined by the operation system.
I use Ubuntu
for the following example.
check which locales are supported:
locale -a
add the locales you want (for example ru
):
sudo locale-gen ru_RU
sudo locale-gen ru_RU.UTF-8
run this update comand
sudo update-locale
restart php fpm ( check your php version service name like soservice --status-all
)
sudo service php7.2-fpm restart
But be careful, because most likely you are useing Apache
with "mod_php" because it is the most popular one. And this one works in multi thread environment, when setlocale() is not thread safe. Look here for details
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With