<?php
// Staring straight up into the sky ... oh my my
/* Возвращает соответствующую числу форму слова: 1 рубль, 2 рубля, 5 рублей */
function addStupidWord( $number , $numberString , $spelling ) {
$lastDigit = $number % 10 ;
$number = $number % 100 ;
if ( $number < 5 ) {
$numberString .= $spelling [ $lastDigit ] ;
} elseif ( $number >= 5 && $number <= 20 ) {
$numberString .= $spelling [ 0 ] ;
} else {
$numberString .= $spelling [ $lastDigit ] ;
}
return $numberString . ' ' ;
}
// Разбираемся с родом числительного
function dealWithGender( $smallNumberString , $lastDigit , $maleSpelling , $isFemale ) {
1 => 'одна' , 2 => 'две'
) ;
if ( ( $lastDigit == 1 || $lastDigit == 2 ) && $isFemale ) {
$smallNumberString .= $femaleSpelling [ $lastDigit ] . ' ' ;
} else {
$smallNumberString .= $maleSpelling . ' ' ;
}
return $smallNumberString ;
}
/*
Преобразует числа от 0 до 999 в текст. Параметр $isFemale равен false,
если мы считаем число для мужского рода (один рубль),
и 1 — для женского (одна тысяча)
*/
function smallNumberToText( $number , $isFemale ) {
0 => 'ноль' , 10 => 'десять' , 100 => 'сто' ,
1 => 'один' , 11 => 'одиннадцать' , 20 => 'двадцать' , 200 => 'двести' ,
2 => 'два' , 12 => 'двенадцать' , 30 => 'тридцать' , 300 => 'триста' ,
3 => 'три' , 13 => 'тринадцать' , 40 => 'сорок' , 400 => 'четыреста' ,
4 => 'четыре' , 14 => 'четырнадцать' , 50 => 'пятьдесят' , 500 => 'пятьсот' ,
5 => 'пять' , 15 => 'пятнадцать' , 60 => 'шестьдесят' , 600 => 'шестьсот' ,
6 => 'шесть' , 16 => 'шестнадцать' , 70 => 'семьдесят' , 700 => 'семьсот' ,
7 => 'семь' , 17 => 'семнадцать' , 80 => 'восемьдесят' , 800 => 'восемьсот' ,
8 => 'восемь' , 18 => 'восемнадцать' , 90 => 'девяносто' , 900 => 'девятьсот' ,
9 => 'девять' , 19 => 'девятнадцать'
) ;
$smallNumberString = '' ;
// last 2 digits
if ( $number >= 100 ) {
$smallNumberString .= $spelling [ $number - $number % 100 ] . ' ' ;
$number = $number % 100 ;
}
//echo "$number<br/>";
//echo "$smallNumberString<br/>";
if ( $number > 0 ) {
$lastDigit = $number % 10 ;
if ( $number < 20 ) { // 0..19
$smallNumberString = dealWithGender( $smallNumberString ,
$number ,
$spelling [ $number ] ,
$isFemale ) ;
} elseif ( $number < 100 ) { // 20..99
$smallNumberString .= $spelling [ ( $number - $lastDigit ) ] . ' ' ;
if ( $lastDigit > 0 ) {
$smallNumberString = dealWithGender( $smallNumberString ,
$lastDigit ,
$spelling [ $lastDigit ] ,
$isFemale ) ;
//echo "$smallNumberString<br/>";
}
}
}
return $smallNumberString ;
}
function numberToText( $number ) {
0 => 'рублей' , 6 => 'рублей' ,
1 => 'рубль' , 7 => 'рублей' ,
2 => 'рубля' , 8 => 'рублей' ,
3 => 'рубля' , 9 => 'рублей' ,
4 => 'рубля' , 10 => 'рублей' ,
5 => 'рублей'
) ;
$spellingThousand = array ( 0 => 'тысяч' , 6 => 'тысяч' ,
1 => 'тысяча' , 7 => 'тысяч' ,
2 => 'тысячи' , 8 => 'тысяч' ,
3 => 'тысячи' , 9 => 'тысяч' ,
4 => 'тысячи' , 10 => 'тысяч' ,
5 => 'тысяч'
) ;
$spellingMillion = array ( 0 => 'миллионов' , 6 => 'миллионов' ,
1 => 'миллион' , 7 => 'миллионов' ,
2 => 'миллиона' , 8 => 'миллионов' ,
3 => 'миллиона' , 9 => 'миллионов' ,
4 => 'миллиона' , 10 => 'миллионов' ,
5 => 'миллионов'
) ;
$spellingBillion = array ( 0 => 'миллиардов' , 6 => 'миллиардов' ,
1 => 'миллиард' , 7 => 'миллиардов' ,
2 => 'миллиарда' , 8 => 'миллиардов' ,
3 => 'миллиарда' , 9 => 'миллиардов' ,
4 => 'миллиарда' , 10 => 'миллиардов' ,
5 => 'миллиардов'
) ;
$numberString = "" ;
if ( $number > 999999 ) {
$smallNumber = floor ( $number / 1000000 ) ; //echo "миллионы = $smallNumber <br/>";
$numberString .= smallNumberToText( $smallNumber , false ) ;
$numberString = addStupidWord( $smallNumber , $numberString , $spellingMillion ) ;
$number -= $smallNumber * 1000000 ;
//echo " чилсо меньше 1000000 = $number <br/>";
}
if ( $number > 999 ) {
$smallNumber = floor ( $number / 1000 ) ; //echo "тысячи = $smallNumber <br/>";
$numberString .= smallNumberToText( $smallNumber , true ) ;
$numberString = addStupidWord( $smallNumber , $numberString , $spellingThousand ) ;
$number -= $smallNumber * 1000 ;
//echo " чилсо меньше 1000 = $number <br/>";
}
if ( $number >= 0 ) {
$smallNumber = floor ( $number / 1 ) ; //echo "рубли = $smallNumber <br/>";
$numberString .= smallNumberToText( $smallNumber , false ) ;
$numberString = addStupidWord( $smallNumber , $numberString , $spellingRubles ) ;
}
return $numberString ;
}
$number = 0 ;
echo "$number = " . numberToText( $number ) . "\n " ;
$number = 100100100 ;
echo "$number = " . numberToText( $number ) . "\n " ;
$number = 1000001 ;
echo "$number = " . numberToText( $number ) . "\n " ;
$number = 15015015 ;
echo "$number = " . numberToText( $number ) . "\n " ;
$number = 1000 ;
echo "$number = " . numberToText( $number ) . "\n " ;
$number = 1 ;
echo "$number = " . numberToText( $number ) . "\n " ;
$number = 1007099 ;
echo "$number = " . numberToText( $number ) . "\n " ;
//$number = 70405080;
//echo "$number = ".numberToText($number)."<br/>";
for ( $i = 0 ; $i < 5 ; $i ++ ) {
$number = rand ( 1 , 1000000000 ) ; echo "$number = " . numberToText( $number ) . " \n " ;
}
PD9waHAKCi8vIFN0YXJpbmcgc3RyYWlnaHQgdXAgaW50byB0aGUgc2t5IC4uLiBvaCBteSBteQplcnJvcl9yZXBvcnRpbmcoLTEpOwptYl9pbnRlcm5hbF9lbmNvZGluZygndXRmLTgnKTsKCi8qINCS0L7Qt9Cy0YDQsNGJ0LDQtdGCINGB0L7QvtGC0LLQtdGC0YHRgtCy0YPRjtGJ0YPRjiDRh9C40YHQu9GDINGE0L7RgNC80YMg0YHQu9C+0LLQsDogMSDRgNGD0LHQu9GMLCAy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Zzxici8+IjsKICAgIGlmICgkbnVtYmVyID4gMCkgewogICAgICAgICRsYXN0RGlnaXQgPSAkbnVtYmVyICUgMTA7CiAgICAgICAgaWYgKCRudW1iZXIgPCAyMCkgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAwLi4xOQogICAgICAgICAgICAkc21hbGxOdW1iZXJTdHJpbmcgPSBkZWFsV2l0aEdlbmRlcigkc21hbGxOdW1iZXJTdHJpbmcsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICRudW1iZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICRzcGVsbGluZ1skbnVtYmVyXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJGlzRmVtYWxlKTsKCiAgICAgICAgfSBlbHNlaWYgKCRudW1iZXIgPCAxMDApIHsgICAgICAgICAgICAgICAgICAgICAgIC8vIDIwLi45OQoKICAgICAgICAgICAgJHNtYWxsTnVtYmVyU3RyaW5nIC49ICRzcGVsbGluZ1soJG51bWJlciAtICRsYXN0RGlnaXQpXSAuICcgJzsKICAgICAgICAgICAgaWYgKCRsYXN0RGlnaXQgPiAwKSB7CiAgICAgICAgICAgICAgICAkc21hbGxOdW1iZXJTdHJpbmcgPSBkZWFsV2l0aEdlbmRlcigkc21hbGxOdW1iZXJTdHJpbmcsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkbGFzdERpZ2l0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJHNwZWxsaW5nWyRsYXN0RGlnaXRdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJGlzRmVtYWxlKTsKICAgICAgICAgICAgICAgIC8vZWNobyAiJHNtYWxsTnVtYmVyU3RyaW5nPGJyLz4iOwogICAgICAgICAgICB9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0nLCAgNyA9PiAn0LzQuNC70LvQuNC+0L3QvtCyJywKICAgICAgICAyID0+ICfQvNC40LvQu9C40L7QvdCwJywgIDggPT4gJ9C80LjQu9C70LjQvtC90L7QsicsCiAgICAgICAgMyA9PiAn0LzQuNC70LvQuNC+0L3QsCcsICA5ID0+ICfQvNC40LvQu9C40L7QvdC+0LInLAogICAgICAgIDQgPT4gJ9C80LjQu9C70LjQvtC90LAnLCAgMTAgPT4gJ9C80LjQu9C70LjQvtC90L7QsicsCiAgICAgICAgNSA9PiAn0LzQuNC70LvQuNC+0L3QvtCyJwogICAgKTsKICAgICRzcGVsbGluZ0JpbGxpb24gPSBhcnJheSAoCiAgICAgICAgMCA9PiAn0LzQuNC70LvQuNCw0YDQtNC+0LInLCA2ID0+ICfQvNC40LvQu9C40LDRgNC00L7QsicsCiAgICAgICAgMSA9PiAn0LzQuNC70LvQuNCw0YDQtCcsICA3ID0+ICfQvNC40LvQu9C40LDRgNC00L7QsicsCiAgICAgICAgMiA9PiAn0LzQuNC70LvQuNCw0YDQtNCwJywgIDggPT4gJ9C80LjQu9C70LjQsNGA0LTQvtCyJywKICAgICAgICAzID0+ICfQvNC40LvQu9C40LDRgNC00LAnLCAgOSA9PiAn0LzQuNC70LvQuNCw0YDQtNC+0LInLAogICAgICAgIDQgPT4gJ9C80LjQu9C70LjQsNGA0LTQsCcsICAxMCA9PiAn0LzQuNC70LvQuNCw0YDQtNC+0LInLAogICAgICAgIDUgPT4gJ9C80LjQu9C70LjQsNGA0LTQvtCyJwogICAgKTsKCiAgICAkbnVtYmVyU3RyaW5nID0gIiI7CiAgICBpZigkbnVtYmVyID4gOTk5OTk5KSB7CiAgICAgICAgJHNtYWxsTnVtYmVyID0gZmxvb3IoJG51bWJlciAvIDEwMDAwMDApOwogICAgICAgIC8vZWNobyAi0LzQuNC70LvQuNC+0L3RiyA9ICRzbWFsbE51bWJlciA8YnIvPiI7CiAgICAgICAgJG51bWJlclN0cmluZyAuPSBzbWFsbE51bWJl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