<?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(123);
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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