<?php
function smallNumberToText($number) {
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 => 'девятнадцать'
);
1 => 'одна', 2 => 'две'
);
$from1to900 = '#^[1-9]0?0?$#';
$from11to19 = '#^[11-19]$#';
$first; $second; $third;
$res = "";
if ($number == 0){
return $spelling[$number];
}
return $spelling[$number];
}
return $spelling[$number];
}
else{
$first = floor($number / 100)*100; $second = floor(($number - $first)/10)*10; $third = $second -(floor($second/10) * 10); if(($first != 0)&&($second != 0)&&($third != 0)){
$res = $spelling[$first]." ".$spelling[$second]." ".$spelling[$third];
}
return $res;
}
}
$num = 423;
$small = smallNumberToText($num);
echo $small;
PD9waHAKCmZ1bmN0aW9uIHNtYWxsTnVtYmVyVG9UZXh0KCRudW1iZXIpIHsKCiAgICAkc3BlbGxpbmcgPSBhcnJheSgKICAgICAgICAwICAgPT4gICfQvdC+0LvRjCcsICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDEwICA9PiAgJ9C00LXRgdGP0YLRjCcsICAgICAgIDEwMCA9PiAgJ9GB0YLQvicsCiAgICAgICAgMSAgID0+ICAn0L7QtNC40L0nLCAgICAgICAgIDExICA9PiAgJ9C+0LTQuNC90L3QsNC00YbQsNGC0YwnLCAgICAgIDIwICA9PiAgJ9C00LLQs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