function rusInducing num words out if strlen num if substr num switch

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function rusInducing($num, $words)
{
$out = "";
if (strlen($num)>1)
{
if (substr($num, 0, 1)!='1')
{
switch(substr($num, 1, 1))
{
case 1:
$out = $words[0];
break;
case 2:
case 3:
case 4:
$out = $words[1];
break;
case 5:
case 6:
case 7:
case 8:
case 9:
case 0:
$out = $words[2];
break;
}
}
else
{
$out = $words[2];
}
}
else
{
switch ($num)
{
case 1:
$out = $words[0];
break;
case 2:
case 3:
case 4:
$out = $words[1];
break;
case 5:
case 7:
case 8:
case 9:
case 0:
$out = $words[2];
break;
}
}
return $out;
}