<?php
/* Возвращает соответствующую числу форму слова: 1 рубль, 2 рубля, 5 рублей */
function inclineWord($discharge, $key) {
0 => "миллион",
1 => "миллиона",
2 => "миллионов"
),
0 => "тысяча",
1 => "тысячи",
2 => "тысяч"
),
0 => "рубль",
1 => "рубля",
2 => "рублей"
)
);
$word = $discharge % 10;
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 "На вашем счету ноль рублей";
}
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 == 8) {
} elseif ($score == 7) {
}
0 => $million,
1 => $thousand,
2 => $hundred
);
$number = "";
foreach($level as $key => $discharge) {
if ($discharge > 0) {
$numberDigits = 1000;
$numberDigits = 100;
$numberDigits = 10;
}
for ($i = 0; $i < mb_strlen($discharge); $i++) {
$numberDigits = $numberDigits / 10;
$words = inclineWord($discharge, $key);
$number = $number.' '.$spelling[mb_substr($discharge, $i, 1) * $numberDigits]; }
$number = $number.' '.$words;
}
}
0 => '/ десять один/u',
1 => '/ десять два/u',
2 => '/ десять три/u',
3 => '/ десять четыре/u',
4 => '/ десять пять/u',
5 => '/ десять шесть/u',
6 => '/ десять семь/u',
7 => '/ десять восемь/u',
8 => '/ десять девять/u'
);
$regexp = array ('/один тысяча/u', '/два тысячи/u', '/ноль|^[ ]/u', '/[ ]{2,}/u'); $replacements = array ('одна тысяча', 'две тысячи', '', ' ');
return($number);
}
$number = smallNumberToText($number);
echo "На вашем счету {$number}\n";
PD9waHAKIAplcnJvcl9yZXBvcnRpbmcoLTEpOwptYl9pbnRlcm5hbF9lbmNvZGluZygndXRmLTgnKTsKIAogCi8qINCS0L7Qt9Cy0YDQsNGJ0LDQtdGCINGB0L7QvtGC0LLQtdGC0YHRgtCy0YPRjtGJ0YPRjiDRh9C40YHQu9GDINGE0L7RgNC80YMg0YHQu9C+0LLQsDogMSDRgNGD0LHQu9GMLCAyINGA0YPQsdC70Y8sIDUg0YDRg9Cx0LvQtdC5ICovCmZ1bmN0aW9uIGluY2xpbmVXb3JkKCRkaXNjaGFyZ2UsICRrZXkpIHsKIAogICAgJGVuZCA9IGFycmF5KAoJICAgIDAgPT4gYXJyYXkoCgkJICAgIDAgPT4gItC80LjQu9C70LjQvtC9IiwKCQkJMSA9PiAi0LzQuNC70LvQuNC+0L3QsCIsCgkJCTIgPT4gItC80LjQu9C70LjQvtC90L7QsiIKCQkpLAoJCTEgPT4gYXJyYXkoCgkJICAgIDAgPT4gItGC0YvRgdGP0YfQsCIsCgkJCTEgPT4gItGC0YvRgdGP0YfQuCIsCgkJCTIgPT4gItGC0YvRgdGP0YciCgkJKSwKCQkyID0+IGFycmF5KAoJCSAgICAwID0+ICLRgNGD0LHQu9GMIiwKCQkJMSA9PiAi0YDRg9Cx0LvRjyIsCgkJCTIgPT4gItGA0YPQsdC70LXQuSIKCQkpCiAgICApOwogCgkkd29yZCA9ICRkaXNjaGFyZ2UgJSAxMDsKIAogICAgaWYgKCR3b3JkID09IDEpewogICAgICAgICR3b3JkID0gJGVuZFska2V5XVswXTsKICAgIH0gZWxzZWlmICgoJHdvcmQgPj0gMikgJiYgKCR3b3JkIDw9IDQpKSB7CgkgICAgJHdvcmQgPSAkZW5kWyRrZXldWzFdOwogICAgfSBlbHNlIHsKCSAgICAkd29yZCA9ICRlbmRbJGtleV1bMl07CiAgICB9CiAKCXJldHVybigkd29yZCk7Cn0KIAovL9C/0LXRgNC10LLQvtC00LjRgiDRh9C40YHQu9C+0LLQvtC1INGH0LjRgdC70L4g0LIg0YLQtdC60YHRgtC+0LLQvtC1IApmdW5jdGlvbiBzbWFsbE51bWJlclRvVGV4dCgkbnVtYmVyKSB7CgkKCWlmICgkbnVtYmVyID09IDApIHsKCQllY2hvICLQndCwINCy0LDRiNC10Lwg0YHRh9C10YLRgyDQvdC+0LvRjCDRgNGD0LHQu9C10LkiOwoJCWV4aXQ7Cgl9CiAKICAgICRzcGVsbGluZyA9IGFycmF5KAogICAgICAgIDAgICA9PiAgJ9C90L7Qu9GMJywgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgMSAgID0+ICAn0L7QtNC40L0nLCAgICAgICAgICAgICAgICAgICAKICAgICAgICAyICAgPT4gICfQtNCy0LAnLCAgICAgICAgICAgICAgICAgICAKICAgICAgICAzICAgPT4gICfRgtGA0LgnLCAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgIDQgICA9PiAgJ9GH0LXRgtGL0YDQtScsICAgICAgICAgICAgICAKICAgICAgICA1ICAgPT4gICfQv9GP0YLRjCcsICAgICAgICAgICAgICAgIAogICAgICAgIDYgICA9PiAgJ9GI0LXRgdGC0YwnLCAgICAgICAgICAgICAgICAgICAKICAgICAgICA3ICAgPT4gICfRgdC10LzRjCcsICAgICAgICAgICAgICAgICAKICAgICAgICA4ICAgPT4gICfQstC+0YHQtdC80YwnLCAgICAgICAgICAgIAogICAgICAgIDkgICA9PiAgJ9C00LXQstGP0YLRjCcsCiAgICAgICAgMTAgID0+ICAn0LT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