<?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 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 => 'девятьсот',
);
//разбивает число на миллионы, тысяча и сотни
if ($score >= 6) {
} elseif ($score == 5) {
} elseif ($score == 4) {
}
if ($score == 9) {
} elseif ($score == 8) {
} elseif ($score == 7) {
}
0 => $million,
1 => $thousand,
2 => $hundred
);
$text = "";
foreach($level as $key => $discharge) {
if ($discharge > 0) {
$text = $text.' '.$spelling[mb_substr($discharge, 0, 1) * 100]; }
$text = $text.' '.$spelling[mb_substr($discharge, -2)]; $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('одна тысяча', 'две тысячи', '', '');
$text = $text.' '.'рублей';
}
return($text);
}
$number = smallNumberToText($number);
echo "На вашем счету {$number}\n";
PD9waHAKIAplcnJvcl9yZXBvcnRpbmcoLTEpOwptYl9pbnRlcm5hbF9lbmNvZGluZygndXRmLTgnKTsKIAogCi8qINCS0L7Qt9Cy0YDQsNGJ0LDQtdGCINGB0L7QvtGC0LLQtdGC0YHRgtCy0YPRjtGJ0YPRjiDRh9C40YHQu9GDINGE0L7RgNC80YMg0YHQu9C+0LLQsDogMSDRgNGD0LHQu9GMLCAyINGA0YPQsdC70Y8sIDUg0YDRg9Cx0LvQtdC5ICovCmZ1bmN0aW9uIGluY2xpbmVXb3JkKCRrZXksICR3b3JkKSB7CiAKICAgICRlbmQgPSBhcnJheSgKCSAgICAwID0+IGFycmF5KAoJCSAgICAwID0+ICLQvNC40LvQu9C40L7QvSIsCgkJCTEgPT4gItC80LjQu9C70LjQvtC90LAiLAoJCQkyID0+ICLQvNC40LvQu9C40L7QvdC+0LIiCgkJKSwKCQkxID0+IGFycmF5KAoJCSAgICAwID0+ICLRgtGL0YHRj9GH0LAiLAoJCQkxID0+ICLRgtGL0YHRj9GH0LgiLAoJCQkyID0+ICLRgtGL0YHRj9GHIgoJCSksCgkJMiA9PiBhcnJheSgKCQkgICAgMCA9PiAi0YDRg9Cx0LvRjCIsCgkJCTEgPT4gItGA0YPQsdC70Y8iLAoJCQkyID0+ICLRgNGD0LHQu9C10LkiCgkJKQogICAgKTsKIAogICAgaWYgKCR3b3JkID09IDEpewogICAgICAgICR3b3JkID0gJGVuZFska2V5XVswXTsKICAgIH0gZWxzZWlmICgoJHdvcmQgPj0gMikgJiYgKCR3b3JkIDw9IDQpKSB7CgkgICAgJHdvcmQgPSAkZW5kWyRrZXldWzFdOwogICAgfSBlbHNlIHsKCSAgICAkd29yZCA9ICRlbmRbJGtleV1bMl07CiAgICB9CiAKCXJldHVybigkd29yZCk7Cn0KIAovL9C/0LXRgNC10LLQvtC00LjRgiDRh9C40YHQu9C+0LLQvtC1INGH0LjRgdC70L4g0LIg0YLQtdC60YHRgtC+0LLQvtC1IApmdW5jdGlvbiBzbWFsbE51bWJlclRvVGV4dCgkbnVtYmVyKSB7CgkKCWlmICgkbnVtYmVyID09IDApIHsKCQllY2hvICLQndCwINCy0LDRiNC10Lwg0YHRh9C10YLRgyDQvdC+0LvRjCDRgNGD0LHQu9C10LlcbiI7CgkJZXhpdDsKCX0KCQogICAgJHNwZWxsaW5nID0gYXJyYXkoCiAgICAgICAgMCAgID0+ICAn0L3QvtC70YwnLCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAxICAgPT4gICfQvtC00LjQvScsICAgICAgICAgICAgICAgICAgIAogICAgICAgIDIgICA9PiAgJ9C00LLQsCcsICAgICAgICAgICAgICAgICAgIAogICAgICAgIDMgICA9PiAgJ9GC0YDQuCcsICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgNCAgID0+ICAn0YfQtdGC0YvRgNC1JywgICAgICAgICAgICAgIAogICAgICAgIDUgICA9PiAgJ9C/0Y/RgtGMJywgICAgICAgICAgICAgICAgCiAgICAgICAgNiAgID0+ICAn0YjQtdGB0YLRjCcsICAgICAgICAgICAgICAgICAgIAogICAgICAgIDcgICA9PiAgJ9GB0LXQvNGMJywgICAgICAgICAgICAgICAgIAogICAgICAgIDggICA9PiAgJ9Cy0L7RgdC10LzRjCcsICAgICAgICAgICAgCiAgICAgICAgOSAgID0+ICAn0LTQtdCy0Y/RgtGMJywKICAgICAgICAxMCAgPT4gICfQtNC10YHRj9GC0YwnLCAJCiAgICAgICAgMTEgID0+ICAn0L7QtNC40L3QvdCw0LTRhtCw0Y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