我的产品价格是5005000卢比/(50万卢比和5千卢比).我想转换成50.5万卢比.是否有任何
PHP功能来做到这一点.我尝试搜索stackoverflow并继续只获得number_words转换.在一个占地99英亩的地方,他们这样做了:
http://www.99acres.com/Bangalore-Real-Estate.htm.任何人都可以提供帮助
<?PHP function count_digit($number) { return strlen($number); } function divider($number_of_digits) { $tens="1"; if($number_of_digits>8) return 10000000; while(($number_of_digits-1)>0) { $tens.="0"; $number_of_digits--; } return $tens; } //function call $num = "789"; $ext="";//thousand,lac,crore $number_of_digits = count_digit($num); //this is call :) if($number_of_digits>3) { if($number_of_digits%2!=0) $divider=divider($number_of_digits-1); else $divider=divider($number_of_digits); } else $divider=1; $fraction=$num/$divider; $fraction=number_format($fraction,2); if($number_of_digits==4 ||$number_of_digits==5) $ext="k"; if($number_of_digits==6 ||$number_of_digits==7) $ext="Lac"; if($number_of_digits==8 ||$number_of_digits==9) $ext="Cr"; echo $fraction." ".$ext; ?>
>计算number_of_digit
>取(number_of_digit-1)数十位数值
>除以它.
>从数字位数中查找值的扩展名.
>输出将是
123456789 = 12.34 Cr
23456789 = 2.34 Cr
3456789 = 34.56 Lac
456789 = 4.56 Lac
56789 = 56.78 K
6789 = 6.78 K
如果任何测试用例失败.请告诉我.我会纠正