<?php
/*
Возвращает соответствующую числу форму слова: 1 рубль, 2 рубля, 5 рублей.
*/
function inclineWord($num){
floor($num%100) <= 11 && floor($num%100) >= 19 ?
$currency= " рублей" : ( floor($num%10) == 1 ?
$currency = " рубль" : ( floor($num%10) >= 2 && floor($num%10) <= 4 ?
$currency = " рубля" : $currency = " рублей"
)
);
return $currency;
}
function inclineThou($thou){
floor($thou%100) <= 11 && floor($thou%100) >= 19 ?
$value = " тысяч " : ( floor($thou%10) == 1 ?
$value = " тысяча " : ( floor($thou%10) >= 2 && floor($thou%10) <= 4 ?
$value = " тысячи " : $value = " тысяч "
)
);
}
function inclineMill($mill){
floor($mill%100) <= 11 && floor($mill%100) >= 19 ?
$value = " миллионов " : ( floor($mill%10) == 1 ?
$value = " миллион " : ( floor($mill%10) >= 2 && floor($mill%10) <= 4 ?
$value = " миллиона " : $value = " миллионов "
)
);
}
function assemblyFunc($num){
global $units, $from11To19, $tens, $hundreds, $thousands, $millions;
foreach($numericArr as $key => $triple){
global $units, $from11To19, $tens, $hundreds, $thousands, $millions;
foreach($numericArrDouble as $key => $unit){
global $units, $from11To19, $tens, $hundreds, $thousands, $millions;
$numericArrDouble[0] = $hundreds[$unit];
if($numericArrDouble[1] == 1){
$numericArrDouble[1] = $from11To19[$unit];
}else{
$numericArrDouble[1] = $tens[$unit];
$numericArrDouble[2] = $units[$unit];
}
$partNumStr = implode(" ", $numericArrDouble); return $partNumStr;
}return $partNumStr;
}
}
$a = assemblyFunc(1);
echo $a;
//==============================Склад массивов==============================//
$units = [
1 => 'один', 2 => 'два', 3 => 'три', 4 => 'четыре', 5 => 'пять',
6 => 'шесть', 7 => 'семь', 8 => 'восемь', 9 => 'девять',
];
$from11To19 = [
1 => 'одиннадцать', 2 => 'двенадцать', 3 => 'тринадцать',
4 => 'четырнадцать', 5 => 'пятнадцать', 6 => 'шестнадцать',
7 => 'семнадцать', 8 => 'восемнадцать', 9 => 'девятнадцать'
];
$tens = [
1 => 'десять', 2 => 'двадцать', 3 => 'тридцать', 4 => 'сорок',
5 => 'пятьдесят', 6 => 'шестьдесят', 7 => 'семьдесят',
8 => 'восемьдесят', 9 => 'девяносто'
];
$hundreds = [
1 => 'сто', 2 => 'двести', 3 => 'триста', 4 => 'четыреста',
5 => 'пятьсот', 6 => 'шестьсот', 7 => 'семьсот',
8 => 'восемьсот', 9 => 'девятьсот',
];
$thousands = [
1 => "тысяча", 2 => "тысячи", 5 => "тысяч"
];
$millions = [
1 => "миллион", 2 => "миллиона", 5 => "миллионов"
];
$smallFemalUnitsArr = [
1 => 'одна', 2 => 'две'
];
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwogICAgIAogICAgIAovKgrQktC+0LfQstGA0LDRidCw0LXRgiDRgdC+0L7RgtCy0LXRgtGB0YLQstGD0Y7RidGD0Y4g0YfQuNGB0LvRgyDRhNC+0YDQvNGDINGB0LvQvtCy0LA6IDEg0YDRg9Cx0LvRjCwgMiDRgNGD0LHQu9GPLCA1INGA0YPQsdC70LXQuS4KKi8KCmZ1bmN0aW9uIGluY2xpbmVXb3JkKCRudW0pewogICAgZmxvb3IoJG51bSUxMDApIDw9IDExICYmIGZsb29yKCRudW0lMTAwKSA+PSAxOSA/ICRjdXJyZW5jeT0gIiDRgNGD0LHQu9C10LkiIDogKAogICAgCWZsb29yKCRudW0lMTApID09IDEgPyAkY3VycmVuY3kgPSAiINGA0YPQsdC70YwiIDogKAogICAgCQlmbG9vcigkbnVtJTEwKSA+PSAyICYmIGZsb29yKCRudW0lMTApIDw9IDQgPyAkY3VycmVuY3kgPSAiINGA0YPQsdC70Y8iIDoKICAgIAkgICAgCSRjdXJyZW5jeSA9ICIg0YDRg9Cx0LvQtdC5IgogICAgCSkKCSk7CiAgICByZXR1cm4gJGN1cnJlbmN5Owp9CgpmdW5jdGlvbiBpbmNsaW5lVGhvdSgkdGhvdSl7CglmbG9vcigkdGhvdSUxMDApIDw9IDExICYm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