PHP show money_format without currency text

为君一笑 提交于 2019-12-03 15:06:22

问题


In PHP, is it possible to use money_format to display money without showing the currency or at least showing it in an abbreviated form?

Currently, I use:

$money = "1234.56";
setlocale("LC_ALL", "de_DE");
$money = money_format("%n", $money);

回答1:


!

Seriously. that's the flag:

$money = money_format("%!n", $money);



回答2:


try number_format($money)

http://php.net/manual/en/function.number-format.php




回答3:


// this if for Malaysia  , you can check according to your locality

$number = new NumberFormatter($locale = 'ms_MS.utf8', NumberFormatter::DECIMAL);
    echo $nmuber->format($amount)."\n"; ## 20,00,00,00,000
// if this give error 
Class 'NumberFormatter' not found
// for this  you can do  you can do a
apt-get install php7.0-intl


来源:https://stackoverflow.com/questions/6587179/php-show-money-format-without-currency-text

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!