PHP - setlocale(LC_MONETARY,'en_IN'); 不工作

kri*_*a89 2 php currency-formatting server

我正在尝试将数字字符串转换为印度数字系统(Lakhs格式),为此我用Google搜索并尝试以下代码.

这个代码部分在linux共享托管服务器上测试时给了我正确的输出,但它不能在windows共享主机中工作,不确定这是否是由于某些版本问题,任何线索是否有任何替代setlocate

$amount = '120090';
setlocale(LC_MONETARY, 'en_IN');
$amount = money_format('%!i', $amount);
print $amount;
Run Code Online (Sandbox Code Playgroud)

rra*_*ray 5

这个函数在windows上不起作用,doc说:

仅当系统具有strfmon功能时才定义函数money_format().例如,Windows没有,因此在Windows中未定义money_format().

一种替代方法是intl(需要通过php.ini启用)库和numberFormatter类参见示例:

在PHP中打印货币数字格式