Defining cross-platform money_format function (Linux and Windows)

前端 未结 2 657
一向
一向 2021-01-05 06:08

I have read that money_format is not available on windows, and on some Linux distributions (i.e. BSD 4.11 variants). But I want to write cross-platform library using normal

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-05 06:27

    The money_format() is not worked on Windows machine. So here is your solution for Indian currency format:

    3 && ($i-1)%2==0) )&& $i!=$length){
                    $delimiter .=',';
                }
                $delimiter .=$money[$i];
            }
    
            $result = strrev($delimiter);
            $decimal = preg_replace("/0\./i", ".", $decimal);
            $decimal = substr($decimal, 0, 3);
    
            if( $decimal != '0'){
                $result = $result.$decimal;
            }
    
            return $result;
        }
    ?>
    

提交回复
热议问题