<?php
// Staring straight up into the sky ... oh my my
$word1 = "рубль";
$word2 = "рубля";
$word5 = "рублей";
$number = 131102;
function inclineWord($number, $word1, $word2, $word5)
{
$number = $number % 10;
$arrWord2 = array(2,3,4); $arrWord5 = array(5,6,7,8,9); foreach ($arrWord1 as $arr1) {
if ($number == $arr1) {
return $word1;
}
}
foreach ($arrWord2 as $arr2) {
if ($number == $arr2) {
return $word2;
}
}
foreach ($arrWord5 as $arr5) {
if ($number == $arr5) {
return $word5;
}
else {
$number = $number % 100;
}
}
$arrWord1 = array(21, 31, 41, 51, 61, 71, 81, 91); $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); $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 );
foreach ($arrWord1 as $arr1) {
if ($number == $arr1) {
return $word1;
}
}
foreach ($arrWord2 as $arr2) {
if ($number == $arr2) {
return $word2;
}
}
foreach ($arrWord5 as $arr5) {
if ($number == $arr5) {
return $word5;
}
}
if ($number==0)
{
return $word5;
}
}
$result = inclineWord($number, $word1, $word2, $word5);
$result2 = $number . " {$result}";
echo $result2;
PD9waHAKCi8vIFN0YXJpbmcgc3RyYWlnaHQgdXAgaW50byB0aGUgc2t5IC4uLiBvaCBteSBteQplcnJvcl9yZXBvcnRpbmcoLTEpOwoKJHdvcmQxID0gItGA0YPQsdC70YwiOwokd29yZDIgPSAi0YDRg9Cx0LvRjyI7CiR3b3JkNSA9ICLRgNGD0LHQu9C10LkiOwokbnVtYmVyID0gMTMxMTAyOwpmdW5jdGlvbiBpbmNsaW5lV29yZCgkbnVtYmVyLCAkd29yZDEsICR3b3JkMi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