<?php
/* Возвращает соответствующую числу форму слова: 1 рубль, 2 рубля, 5 рублей */
function inclineWord($key, $word) {
0 => "миллион",
1 => "миллиона",
2 => "миллионов"
),
0 => "тысяча",
1 => "тысячи",
2 => "тысяч"
),
0 => "рубль",
1 => "рубля",
2 => "рублей"
)
);
if ($word == 1){
$word = $end[$key][0];
} elseif (($word >= 2) && ($word <= 4)) {
$word = $end[$key][1];
} else {
$word = $end[$key][2];
}
return($word);
}
//разбивает число на миллионы, тысяча и сотни
function parts($number) {
$hundred = $number % 1000;
if ($score >= 6) {
} elseif ($score == 5) {
} elseif ($score == 4) {
}
if ($score == 9) {
} elseif ($score == 8) {
} elseif ($score == 7) {
}
0 => $million,
1 => $thousand,
2 => $hundred
);
return($level);
}
//переводит числовое число в текстовое
function smallNumberToText($number) {
if ($number == 0) {
echo "На вашем счету ноль рублей\n";
}
0 => 'ноль',
1 => 'один',
2 => 'два',
3 => 'три',
4 => 'четыре',
5 => 'пять',
6 => 'шесть',
7 => 'семь',
8 => 'восемь',
9 => 'девять',
10 => 'десять',
11 => 'одиннадцать',
12 => 'двенадцать',
13 => 'тринадцать',
14 => 'четырнадцать',
15 => 'пятнадцать',
16 => 'шестнадцать',
17 => 'семнадцать',
18 => 'восемнадцать',
19 => 'девятнадцать',
20 => 'двадцать',
30 => 'тридцать',
40 => 'сорок',
50 => 'пятьдесят',
60 => 'шестьдесят',
70 => 'семьдесят',
80 => 'восемьдесят',
90 => 'девяносто',
100 => 'сто',
200 => 'двести',
300 => 'триста',
400 => 'четыреста',
500 => 'пятьсот',
600 => 'шестьсот',
700 => 'семьсот',
800 => 'восемьсот',
900 => 'девятьсот',
);
$level = parts($number);
$text = "";
foreach($level as $key => $discharge) {
if ($discharge > 0) {
$text = $text.' '.$spelling[mb_substr($discharge, 0, 1) * 100]; }
if (($discharge % 100 >= 10) && ($discharge % 100 <= 19)) {
$text = $text.' '.$spelling[$discharge % 100];
$word = $discharge;
$words = inclineWord($key, $word);
$text = $text.' '.$words;
} else {
$numberDigits = 100;
$numberDigits = 10;
}
for ($i = 0; $i < mb_strlen($discharge); $i++) { $numberDigits = $numberDigits / 10;
$text = $text.' '.$spelling[mb_substr($discharge, $i, 1) * $numberDigits]; }
$word = $discharge % 10;
$words = inclineWord($key, $word);
$text = $text.' '.$words;
}
}
}
$regexp = array('/один тысяча/', '/два тысячи/', '/ ноль/', '/^[ ]/'); $replacements = array('одна тысяча', 'две тысячи', '', '');
if ($number % 1000 == 000) {
$text = $text.' '.'рублей';
}
return($text);
}
$number = smallNumberToText($number);
echo "На вашем счету {$number}\n";
PD9waHAKIAplcnJvcl9yZXBvcnRpbmcoLTEpOwptYl9pbnRlcm5hbF9lbmNvZGluZygndXRmLTgnKTsKIAogCi8qINCS0L7Qt9Cy0YDQsNGJ0LDQtdGCINGB0L7QvtGC0LLQtdGC0YHRgtCy0YPRjtGJ0YPRjiDRh9C40YHQu9GDINGE0L7RgNC80YMg0YHQu9C+0LLQsDogMSDRgNGD0LHQu9GMLCAyINGA0YPQsdC70Y8sIDUg0YDRg9Cx0LvQtdC5ICovCmZ1bmN0aW9uIGluY2xpbmVXb3JkKCRrZXksICR3b3JkKSB7CiAKICAgICRlbmQgPSBhcnJheSgKCSAgICAwID0+IGFycmF5KAoJCSAgICAwID0+ICLQvNC40LvQu9C40L7QvSIsCgkJCTEgPT4gItC80LjQu9C70LjQvtC90LAiLAoJCQkyID0+ICLQvNC40LvQu9C40L7QvdC+0LIiCgkJKSwKCQkxID0+IGFycmF5KAoJCSAgICAwID0+ICLRgtGL0YHRj9GH0LAiLAoJCQkxID0+ICLRgtGL0YHRj9GH0LgiLAoJCQkyID0+ICLRgtGL0YHRj9GHIgoJCSksCgkJMiA9PiBhcnJheSgKCQkgICAgMCA9PiAi0YDRg9Cx0LvRjCIsCgkJCTEgPT4gItGA0YPQsdC70Y8iLAoJCQkyID0+ICLRgNGD0LHQu9C10LkiCgkJKQogICAgKTsKIAogICAgaWYgKCR3b3JkID09IDEpewogICAgICAgICR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Gh1bmRyZWQKCSk7CgkKCXJldHVybigkbGV2ZWwpOwp9CiAKLy/Qv9C10YDQtdCy0L7QtNC40YIg0YfQuNGB0LvQvtCy0L7QtSDRh9C40YHQu9C+INCyINGC0LXQutGB0YLQvtCy0L7QtSAKZnVuY3Rpb24gc21hbGxOdW1iZXJUb1RleHQoJG51bWJlcikgewoKCQoJaWYgKCRudW1iZXIgPT0gMCkgewoJCWVjaG8gItCd0LAg0LLQsNGI0LXQvCDRgdGH0LXRgtGDINC90L7Qu9GMINGA0YPQsdC70LXQuVxuIjsKCQlleGl0OwoJfQoJCiAgICAkc3BlbGxpbmcgPSBhcnJheSgKICAgICAgICAwICAgPT4gICfQvdC+0LvRjCcsICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgIDEgICA9PiAgJ9C+0LTQuNC9JywgICAgICAgICAgICAgICAgICAgCiAgICAgICAgMiAgID0+ICAn0LTQstCwJywgICAgICAgICAgICAgICAgICAgCiAgICAgICAgMyAgID0+ICAn0YLRgNC4JywgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICA0ICAgPT4gICfRh9C10YLRi9GA0LUnLCAgICAgICAgICAgICAgCiAgICAgICAgNSAgID0+ICAn0L/Rj9GC0YwnLCAgICAgICAgICAgICAgICAKICAgICAgICA2ICAgPT4gICfRiNC10YHRgtGMJywgICAgICAgICAgICAgICAgICAgCiAgICAgICAgNyAgID0+ICAn0YHQtdC80YwnLCAgICAgICAgICAgICAgICAgCiAgICAgICAgOCAgID0+ICAn0LLQvtGB0LXQvNGMJywgICAgICAgICAgICAKICAgICAgICA5ICAgPT4gICfQtNC10LLRj9GC0YwnLAogICAgICAgIDEwICA9PiAgJ9C00LXRgdGP0YLRjCcsIAkKICAgICAgICAxMSAgPT4gICfQvtC00LjQvdC90LDQtNGG0LDRgtGMJywJCiAgICAgICAgMTIgID0+ICAn0LTQstC10L3QsNC00YbQsNGC0YwnLCAgCiAgICAgICAgMTMgID0+ICAn0YLRgNC40L3QsNC00YbQsNGC0YwnLCAKICAgICAgICAxNCAgPT4gICfRh9C10YLRi9GA0L3QsNC00YbQsNGC0YwnLCAgCiAgICAgICAgMTUgID0+ICAn0L/Rj9GC0L3QsNC00YbQsNGC0YwnLCAgIAogICAgICAgIDE2ICA9PiAgJ9GI0LXRgdGC0L3QsNC00YbQsNGC0YwnLCAKICAgICAgICAxNyAgPT4gICfRgdC10LzQvdCw0LTRhtCw0YLRjCcsICAKICAgICAgICAxOCAgPT4gICfQstC+0YHQtdC80L3QsNC00YbQsNGC0YwnLCAgICAKCSAgICAxOSAgPT4gICfQtNC10LLRj9GC0L3QsNC00YbQsNGC0YwnLCAgCiAgICAgICAgMjAgID0+ICAn0LTQstCw0LTRhtCw0YLRjCcsIAkKICAgICAgICAzMCAgPT4gICfRgtGA0LjQtNGG0LDRgtGMJywKICAgICAgICA0MCAgPT4gICfRgdC+0YDQvtC6JywKICAgICAgICA1MCAgPT4gICfQv9GP0YLRjNC00LXRgdGP0YInLAogICAgICAgIDYwICA9PiAgJ9GI0LXRgdGC0YzQtNC10YHRj9GCJywKICAgICAgICA3MCAgPT4gICfRgdC10LzRjNC00LXRgdGP0YInLCAKICAgICAgICA4MCAgPT4gICfQstC+0YHQtdC80YzQtNC10YHRj9GCJywKICAgICAgICA5MCAgPT4gICfQtNC10LLRj9C90L7RgdGC0L4nLAogICAgICAgIDEwMCA9PiAgJ9GB0YLQvicsCiAgICAgICAgMjAwID0+ICAn0LTQstC10YHRgtC4JywKICAgICAgICAzMDAgPT4gICfRgtGA0LjRgdGC0LAnLAogICAgICAgIDQwMCA9PiAgJ9GH0LXRgtGL0YDQtdGB0YLQsCcsCiAgICAgICAgNTAwID0+ICAn0L/Rj9GC0YzRgdC+0YInLAogICAgICAgIDYwMCA9PiAgJ9GI0LXRgdGC0YzRgdC+0YInLAogICAgICAgIDcwMCA9PiAgJ9GB0LXQvNGM0YHQvtGCJywgCiAgICAgICAgODAwID0+ICAn0LLQvtGB0L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