How to display Currency in Indian Numbering Format in PHP

后端 未结 22 2081
一整个雨季
一整个雨季 2020-12-01 06:14

I have a question about formatting the Rupee currency (Indian Rupee - INR).

For example, numbers here are represented as:

1
10
100
1,000
10,000
1,00,00         


        
22条回答
  •  爱一瞬间的悲伤
    2020-12-01 07:02

    $r=explode('.',12345601.20);
    
    $n = $r[0];
    $len = strlen($n); //lenght of the no
    $num = substr($n,$len-3,3); //get the last 3 digits
    $n = $n/1000; //omit the last 3 digits already stored in $num
    while($n > 0) //loop the process - further get digits 2 by 2
    {
        $len = strlen($n);
        $num = substr($n,$len-2,2).",".$num;
        $n = round($n/100);
    }
    echo "Rs.".$num.'.'.$r[1];
    

提交回复
热议问题