我想知道是否有办法将千位与空间角色分开.
例如:
$number = 21234.56;
setlocale(LC_ALL, 'pl_PL.utf8');
echo money_format('%i', $number);
Run Code Online (Sandbox Code Playgroud)
给我的是:
21.234,56 PLN
而且我要:
21 234,56 PLN
我不想制作str_replace.我相信有更好的方法.
krt*_*tek 19
你可以用number-format.例如 :
echo number_format($number, 2, ',', ' ');
Run Code Online (Sandbox Code Playgroud)
但是你必须自己装置.
否则,此评论中的money_format文档页面给出了一些代码,您可以修改改变千分一版本的功能.
你也可以这样做:
$locale = localeconv();
$text = money_format('%i', $number);
$text = str_replace($locale['mon_thousands_sep'], ' ', $text);
Run Code Online (Sandbox Code Playgroud)
请参阅:http://php.net/manual/en/function.number-format.php
string number_format ( float $number , int $decimals = 0 , string $dec_point = '.' , string $thousands_sep = ',' )
对于你的情况:
number_format($number, 2, ',', ' ');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9927 次 |
| 最近记录: |