Is there any PHP function to convert number to cur

2019-03-04 13:01发布

Is there any PHP function to convert an integer to Lakh and Crore?

900800 -> 9,00,800
500800 -> 5,00,800

2条回答
祖国的老花朵
2楼-- · 2019-03-04 13:26

For most locales, use number_format: http://php.net/manual/en/function.number-format.php

For India (Lakh & Crore) use formatInIndianStyle provided in this comment: http://php.net/manual/en/function.number-format.php#40558

查看更多
我想做一个坏孩纸
3楼-- · 2019-03-04 13:37

As you have added Yii in your question tags, you can do this in Yii's way like below:

Yii::app()->language='en_IN';
// Output: Lakh 9,00,800
echo Yii::app()->numberFormatter->formatCurrency('900800', 'Lakh');

// Output: ₹ 5,00,800
echo Yii::app()->numberFormatter->formatCurrency('500800', 'INR');
查看更多
登录 后发表回答