<?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) {
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 => '/ десять один/',
1 => '/ десять два/',
2 => '/ десять три/',
3 => '/ десять четыре/',
4 => '/ десять пять/',
5 => '/ десять шесть/',
6 => '/ десять семь/',
7 => '/ десять восемь/',
8 => '/ десять девять/'
);
$regexp = '/[ ]ноль[ ]/';
$regexp = array ('/один тысяча/', '/два тысячи/'); $replacements = array ('одна тысяча', 'две тысячи');
return($number);
}
$number = 100000;
$number = smallNumberToText($number);
echo "На вашем счету {$number}\n";
PD9waHAKIAplcnJvcl9yZXBvcnRpbmcoLTEpOwptYl9pbnRlcm5hbF9lbmNvZGluZygndXRmLTgnKTsKIAogCi8qINCS0L7Qt9Cy0YDQsNGJ0LDQtdGCINGB0L7QvtGC0LLQtdGC0YHRgtCy0YPRjtGJ0YPRjiDRh9C40YHQu9GDINGE0L7RgNC80YMg0YHQu9C+0LLQsDogMSDRgNGD0LHQu9GMLCAyINGA0YPQsdC70Y8sIDUg0YDRg9Cx0LvQtdC5ICovCmZ1bmN0aW9uIGluY2xpbmVXb3JkKCRkaXNjaGFyZ2UsICRrZXkpIHsKCQogICAgJGVuZCA9IGFycmF5KAoJICAgIDAgPT4gYXJyYXkoCgkJICAgIDAgPT4gItC80LjQu9C70LjQvtC9IiwKCQkJMSA9PiAi0LzQuNC70LvQuNC+0L3QsCIsCgkJCTIgPT4gItC80LjQu9C70LjQvtC90L7QsiIKCQkpLAoJCTEgPT4gYXJyYXkoCgkJICAgIDAgPT4gItGC0YvRgdGP0YfQsCIsCgkJCTEgPT4gItGC0YvRgdGP0YfQuCIsCgkJCTIgPT4gItGC0YvRgdGP0YciCgkJKSwKCQkyID0+IGFycmF5KAoJCSAgICAwID0+ICLRgNGD0LHQu9GMIiwKCQkJMSA9PiAi0YDRg9Cx0LvRjyIsCgkJCTIgPT4gItGA0YPQsdC70LXQuSIKCQkpCiAgICApOwoJCgkkd29yZCA9ICRkaXNjaGFyZ2UgJSAxMDsKCiAgICBpZiAoJHdvcmQgPT0gMSl7CiAgICAgICAgJHdvcmQgPSAkZW5kWyRrZXldWzBdOwogICAgfSBlbHNlaWYgKCgkd29yZCA+PSAyKSAmJiAoJHdvcmQgPD0gNCkpIHsKCSAgICAkd29yZCA9ICRlbmRbJGtleV1bMV07CiAgICB9IGVsc2UgewoJICAgICR3b3JkID0gJGVuZFska2V5XVsyXTsKICAgIH0KCQoJcmV0dXJuKCR3b3JkKTsKfQogCi8v0L/QtdGA0LXQstC+0LTQuNGCINGH0LjRgdC70L7QstC+0LUg0YfQuNGB0LvQviDQsiDRgtC10LrRgdGC0L7QstC+0LUgCmZ1bmN0aW9uIHNtYWxsTnVtYmVyVG9UZXh0KCRudW1iZXIpIHsKIAogICAgJHNwZWxsaW5nID0gYXJyYXkoCiAgICAgICAgMCAgID0+ICAn0L3QvtC70YwnLCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAxICAgPT4gICfQvtC00LjQvScsICAgICAgICAgICAgICAgICAgIAogICAgICAgIDIgICA9PiAgJ9C00LLQsCcsICAgICAgICAgICAgICAgICAgIAogICAgICAgIDMgICA9PiAgJ9GC0YDQuCcsICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgNCAgID0+ICAn0YfQtdGC0YvRgNC1JywgICAgICAgICAgICAgIAogICAgICAgIDUgICA9PiAgJ9C/0Y/RgtGMJywgICAgICAgICAgICAgICAgCiAgICAgICAgNiAgID0+ICAn0YjQtdGB0YLRjCcsICAgICAgICAgICAgICAgICAgIAogICAgICAgIDcgICA9PiAgJ9GB0LXQvNGMJywgICAgICAgICAgICAgICAgIAogICAgICAgIDggICA9PiAgJ9Cy0L7RgdC10LzRjCcsICAgICAgICAgICAgCiAgICAgICAgOSAgID0+ICAn0LTQtdCy0Y/RgtGMJywKICAgICAgICAxMCAgPT4gICfQtNC10YHRj9GC0YwnLCAJCiAgICAgICAgMTEgID0+ICAnINC+0LTQuNC90L3QsNC00YbQsNGC0YwnLAkKICAgICAgICAxMiAgPT4gICcg0LTQstC10L3QsNC00YbQsNGC0YwnLCAgCiAgICAgICAgMTMgID0+ICAnING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