How to display Currency in Indian Numbering Format in PHP

后端 未结 22 2168
一整个雨季
一整个雨季 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:14

    Above Function Not working with Decimal

    $amount = 10000034000.001;
    $amount = moneyFormatIndia( $amount );
    echo $amount;
    
    
    
    
    function moneyFormatIndia($num){
            $nums = explode(".",$num);
            if(count($nums)>2){
                return "0";
            }else{
            if(count($nums)==1){
                $nums[1]="00";
            }
            $num = $nums[0];
            $explrestunits = "" ;
            if(strlen($num)>3){
                $lastthree = substr($num, strlen($num)-3, strlen($num));
                $restunits = substr($num, 0, strlen($num)-3); 
                $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; 
                $expunit = str_split($restunits, 2);
                for($i=0; $i

    Answer : 10,00,00,34,000.001

提交回复
热议问题