Blogger Information
Blog 17
fans 0
comment 1
visits 21579
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
阿拉伯数字转中文大写
Ant.
Original
1106 people have browsed it
  1. function numberToChinese($number)
  2. {
  3. $number = intval($number);
  4. $bit = array("零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十");
  5. //各位数
  6. if ($number <= 10) {
  7. return $bit[$number];
  8. }
  9. //十位数
  10. if ($number < 100) {
  11. $array = str_split($number);
  12. if ($array[0] < 2) {
  13. return $bit[10] . $bit[$array[1]];
  14. } else {
  15. if ($array[1] == 0) {
  16. return $bit[$array[0]] . $bit[10];
  17. } else {
  18. return $bit[$array[0]] . $bit[10] . $bit[$array[1]];
  19. }
  20. }
  21. }
  22. //百位数
  23. if ($number < 1000) {
  24. $array = str_split($number);
  25. if ($array[1] == 0 && $array[2] == 0) {
  26. return $bit[$array[0]] . "百";
  27. } elseif ($array[1] == 0 && $array[2] != 0) {
  28. return $bit[$array[0]] . "百" . $bit[$array[1]] . $bit[$array[2]];
  29. } elseif ($array[1] != 0 && $array[2] == 0) {
  30. return $bit[$array[0]] . "百" . $bit[$array[1]] . $bit[10];
  31. } else {
  32. return $bit[$array[0]] . "百" . $bit[$array[1]] . $bit[10] . $bit[$array[2]];
  33. }
  34. }
  35. //千位数
  36. if ($number < 10000) {
  37. $array = str_split($number);
  38. if ($array[1] == 0 && $array[2] == 0 && $array[3] == 0) {
  39. return $bit[$array[0]] . "千";
  40. } elseif ($array[1] == 0 && $array[2] != 0 && $array[3] != 0) {
  41. return $bit[$array[0]] . "千" . $bit[$array[1]] . $bit[$array[2]] . $bit[10] . $bit[$array[3]];
  42. } elseif ($array[1] == 0 && $array[2] == 0 && $array[3] != 0) {
  43. return $bit[$array[0]] . "千" . $bit[$array[1]] . $bit[$array[3]];
  44. } elseif ($array[1] == 0 && $array[2] != 0 && $array[3] == 0) {
  45. return $bit[$array[0]] . "千" . $bit[$array[1]] . $bit[$array[2]] . $bit[10];
  46. } elseif ($array[1] != 0 && $array[2] == 0 && $array[3] == 0) {
  47. return $bit[$array[0]] . "千" . $bit[$array[1]] . "百";
  48. } elseif ($array[1] != 0 && $array[2] != 0 && $array[3] == 0) {
  49. return $bit[$array[0]] . "千" . $bit[$array[1]] . "百" . $bit[$array[2]] . $bit[10];
  50. } elseif ($array[1] != 0 && $array[2] == 0 && $array[3] != 0) {
  51. return $bit[$array[0]] . "千" . $bit[$array[1]] . "百" . $bit[$array[2]] . $bit[$array[3]];
  52. } else {
  53. return $bit[$array[0]] . "千" . $bit[$array[1]] . "百" . $bit[$array[2]] . $bit[10] . $bit[$array[3]];
  54. }
  55. }
  56. return $number;
  57. }
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post