Only converts the lowercase value of an integer to an uppercase value.

Source: Internet
Author: User
Tags ereg
Only converts the lowercase value of an integer to an uppercase value.

  1. /*

  2. Only the lowercase value of an integer can be converted to an uppercase value.
  3. */
  4. Class ChineseNumber
  5. {
  6. // Var $ basical = array (0 => "zero", "one", "two", "three", "four", "five", "six ", "7", "8", "9 ");
  7. Var $ basical = array (0 => "zero", "one", "two", "three", "si", "Wu", "Lu ", "Success", "fail", "fail ");
  8. // Var $ advanced = array (1 => "10", "hundreds", "thousands ");
  9. Var $ advanced = array (1 => "pick", "success", "success ");
  10. Var $ top = array (1 => ");

  11. Var $ level; // level 4

  12. // Convert the number first.

  13. Function small2big ($ number)
  14. {
  15. If ($ number> 999999999999) // it can only process hundreds of billions of records.
  16. Return "the number is too large to be processed. Sorry! ";
  17. If ($ number = 0)
  18. Return "zero ";

  19. For ($ this-> level = 0; $ number> 0.0001; $ this-> level ++, $ number = floor ($ number/10000 ))

  20. {
  21. // For Chinese, it should be a group of four digits.
  22. // The four variables correspond to digits, and digits.
  23. $ N1 = substr ($ number,-1, 1 );
  24. If ($ number> 9)
  25. $ N2 = substr ($ number,-2, 1 );
  26. Else
  27. $ N2 = 0;
  28. If ($ number> 99)
  29. $ N3 = substr ($ number,-3, 1 );
  30. Else
  31. $ N3 = 0;
  32. If ($ number> 999)
  33. $ N4 = substr ($ number,-4, 1 );
  34. Else
  35. $ N4 = 0;

  36. If ($ n4)

  37. $ Parsed [$ this-> level]. = $ this-> basical [$ n4]. $ this-> advanced [3];
  38. Else
  39. If ($ number/10000)> = 1) // if The kilobytes are 0 and the value is greater than 9999
  40. $ Parsed [$ this-> level]. = "zero ";
  41. If ($ n3)
  42. $ Parsed [$ this-> level]. = $ this-> basical [$ n3]. $ this-> advanced [2];
  43. Else
  44. If (! Ereg ("Zero $", $ parsed [$ this-> level]) & ($ number/1000)> = 1) // no two consecutive "zeros" appear
  45. $ Parsed [$ this-> level]. = "zero ";
  46. If ($ n2)
  47. $ Parsed [$ this-> level]. = $ this-> basical [$ n2]. $ this-> advanced [1];
  48. Else
  49. If (! Ereg ("Zero $", $ parsed [$ this-> level]) & ($ number/100)> = 1) // no two consecutive "zeros" appear
  50. $ Parsed [$ this-> level]. = "zero ";
  51. If ($ n1)
  52. $ Parsed [$ this-> level]. = $ this-> basical [$ n1];
  53. }
  54. For ($ this-> level-= 1; $ this-> level> = 0; $ this-> level --)
  55. {
  56. $ Result. = $ parsed [$ this-> level]. $ this-> top [$ this-> level];
  57. }

  58. If (ereg ("Zero $", $ result ))

  59. $ Result = substr ($ result, 0, strlen ($ result)-2 );

  60. Return $ result;

  61. }
  62. };

  63. $ Big = new ChineseNumber ();

  64. Echo $ big-> small2big (1311 );
  65. ?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.