PHP數字金額轉換成中文大寫金額

2021-10-09 06:28:09 字數 792 閱讀 4118

封裝函式如下:

/**

*數字金額轉換成中文大寫金額的函式

*string int $num 要轉換的小寫數字或小寫字串

*return 大寫字母

*小數字為兩位

**/function numtormb($num)

$i = 0;

$c = "";

while (1)

else

//每次將最後一位數字轉化為中文

$p1 = substr($c1, 3 * $n, 3);

$p2 = substr($c2, 3 * $i, 3);

if ($n != '0' || ($n == '0' && ($p2 == '億' || $p2 == '萬' || $p2 == '元')))

else

$i = $i + 1;

//去掉數字最後一位了

$num = $num / 10;

$num = (int)$num;

//結束迴圈

if ($num == 0)

}$j = 0;

$slen = strlen($c);

while ($j < $slen)

$j = $j + 3;

}//這個是為了去掉類似23.0中最後乙個「零」字

if (substr($c, strlen($c)-3, 3) == '零')

//將處理的漢字加上「整」

if (empty($c))

else

}

php實現數字金額轉換成中文大寫金額

header content type text html charset utf 8 數字金額轉換成中文大寫金額的函式 string int num 要轉換的小寫數字或小寫字串 return 大寫字母 小數字為兩位 function num to rmb num i 0 c while 1 els...

小寫金額轉換成中文大寫金額

public string cmycurd decimal num str2 str2.substring 15 j 取出對應位數的str2的值。如 200.55,j為5所以str2 佰拾元角分 迴圈取出每一位需要轉換的值 for i 0 i j i else else else else else...

數字轉換成大寫金額

數字轉換成大寫金額 using system public class numtocaps 將數定轉換大寫金額格式 引數必須小於萬萬億,且不超過兩位小數多過兩位自動擷取兩位 返回大寫金額 public string getcaps decimal d if d 0 if s.length 0 s.l...