fork download
  1. <?php
  2.  
  3. // Staring straight up into the sky ... oh my my
  4.  
  5. $word1 = "рубль";
  6. $word2 = "рубля";
  7. $word5 = "рублей";
  8. $number = 131102;
  9. function inclineWord($number, $word1, $word2, $word5)
  10. {
  11. $number = $number % 10;
  12. $arrWord1 = array(1);
  13. $arrWord2 = array(2,3,4);
  14. $arrWord5 = array(5,6,7,8,9);
  15. foreach ($arrWord1 as $arr1) {
  16. if ($number == $arr1) {
  17. return $word1;
  18. }
  19. }
  20. foreach ($arrWord2 as $arr2) {
  21. if ($number == $arr2) {
  22. return $word2;
  23. }
  24. }
  25. foreach ($arrWord5 as $arr5) {
  26. if ($number == $arr5) {
  27. return $word5;
  28. }
  29. else {
  30. $number = $number % 100;
  31. }
  32. }
  33.  
  34.  
  35. $arrWord1 = array(21, 31, 41, 51, 61, 71, 81, 91);
  36. $arrWord2 = array(22, 23, 24, 32, 33, 34, 42, 43, 44, 52, 53, 54, 62, 63, 64, 72, 73, 74, 82, 83, 84, 92, 93, 94);
  37. $arrWord5 = array(10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 26, 27, 28, 29, 30, 35, 36, 37, 38, 39, 40, 45, 46, 47, 48, 49, 50, 55, 56, 57, 58, 59, 60, 65, 66, 67, 68, 69, 70, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 95, 96, 97, 98,99 );
  38.  
  39. foreach ($arrWord1 as $arr1) {
  40. if ($number == $arr1) {
  41. return $word1;
  42. }
  43. }
  44. foreach ($arrWord2 as $arr2) {
  45. if ($number == $arr2) {
  46. return $word2;
  47. }
  48. }
  49. foreach ($arrWord5 as $arr5) {
  50. if ($number == $arr5) {
  51. return $word5;
  52. }
  53. }
  54. if ($number==0)
  55. {
  56. return $word5;
  57. }
  58. }
  59. $result = inclineWord($number, $word1, $word2, $word5);
  60. $result2 = $number . " {$result}";
  61. echo $result2;
  62.  
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
131102 рубля