@underbottom/

words out of digits

PHP (Legacy)

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.5250612313364562","path":"main.php","file":{"path":"main.php","content":{"asEncoding":{"base64":"PD9waHAKIAovLyBTdGFyaW5nIHN0cmFpZ2h0IHVwIGludG8gdGhlIHNreSAuLi4gb2ggbXkgbXkKZXJyb3JfcmVwb3J0aW5nKC0xKTsKbWJfaW50ZXJuYWxfZW5jb2RpbmcoJ3V0Zi04Jyk7CgoKLy/Qt9Cw0LrQsNC90YfQuNCy0LDQtdC8INC/0YDQtdC+0LHRgNCw0LfQvtCy0LDQvdC40LUKZnVuY3Rpb24gbWFrZVdvcmRPZlRocmVlICgkbnVtYmVyLCRmZW1hbGVTcGVsbGluZywkc3BlbGxpbmcpIHsKICAkaSA9IDA7CiAgLy/Qt9Cw0L/Rg9GB0LrQsNC10Lwg0L/QtdGA0LXQsdC+0YAg0LTQu9GPINC/0YDQtdC+0LHRgNCw0LfQvtCy0LDQvdC40Y8KICBmb3JlYWNoICgkbnVtYmVyIGFzICRrZXkgPT4gJHZhbHVlKXsKICAgICRpKys7CiAgICAkb25lRGlnID0gZmxvb3IoJHZhbHVlIC8gMTAwKSoxMDA7CgogICAgLy/RgNCw0LHQvtGC0LDQtdC8INGBINGB0L7RgtC90Y/QvNC4CiAgICBpZiAoJG9uZURpZyE9MCkgewogICAgICAkZGlnTmFtZSA9ICRzcGVsbGluZ1skb25lRGlnXTsKICAgIH1lbHNlewogICAgICAkZGlnTmFtZSA9ICIiOwogICAgfQoKICAgICRvbmVEaWcgPSAkdmFsdWUgJSAxMDA7CiAgICAkb25lRGlnID0gZmxvb3IgKCRvbmVEaWcvMTApOwoKICAgIC8vINGB0L7RhdGA0LDQvdGP0LXQvCDQtNC10YHRj9GC0L7QuiDQvdCwINC00LvRjyDQtdC00LXQvdC40YYKICAgICRzZWNvbmREaWcgPSAkb25lRGlnOwoKCiAgICAvL9GA0LDQsdC+0YLQsNC10Lw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IgIiwkdGV4dCk7CiAgCiAgcmV0dXJuICR0ZXh0Owp9CgovL9C00LXQu9Cw0LXQvCDQvtGB0L3QvtCy0L3QvtC5INGE0YPQvdC60YbQuNC10Lkg0Lgg0LLRgdGOINGA0LDQsdC+0YLRgyDQv9C10YDQtdC00LDQtdC8INC10LkuCmZ1bmN0aW9uIGNvbnZlcnROdW1iZXJzVG9Xb3JkcyAoJG51bWJlcikgewogICRhY2NvdW50QmFsYW5jZSA9ICIiOwogIAogICRzcGVsbGluZyA9IGFycmF5KAogICAgICAgIDAgICA9PiAgJ9C90L7Qu9GMJywgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMTAgID0+ICAn0LTQtdGB0Y/RgtGMJywgICAgICAgMTAwID0+ICAn0YHRgtC+JywKICAgICAgICAxICAgPT4gICfQvtC00LjQvScsICAgICAgICAgMTEgID0+ICAn0L7QtNC40L3QvdCw0LTRhtCw0YLRjCcsICAgICAgMjAgID0+ICAn0LTQstCw0LTRhtCw0YLRjCcsICAgICAyMDAgPT4gICfQtNCy0LXRgdGC0LgnLAogICAgICAgIDIgICA9PiAgJ9C00LLQsCcsICAgICAgICAgIDEyICA9PiAgJ9C00LLQtdC90LDQtNGG0LDRgtGMJywgICAgICAgMzAgID0+ICAn0YLRgNC40LTRhtCw0YLRjCcsICAgICAzMDAgPT4gICfRgtGA0LjRgdGC0LAnLAogICAgICAgIDMgICA9PiAgJ9GC0YDQuCcsICAgICAgICAgIDEzICA9PiAgJ9GC0YDQuNC90LDQtNGG0LDRgtGMJywgICAgICAgNDAgID0+ICAn0YHQvtGA0L7QuicsICAgICAgICA0MDAgPT4gICfRh9C10YLRi9GA0LXRgdGC0LAnLAogICAgICAgIDQgICA9PiAgJ9GH0LXRgtGL0YDQtScsICAgICAgIDE0ICA9PiAgJ9GH0LXRgtGL0YDQvdCw0LTRhtCw0YLRjCcsICAgICA1MCAgPT4gICfQv9GP0YLRjNC00LXRgdGP0YInLCAgICA1MDAgPT4gICfQv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0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS1cbiI7Cgo/Pg=="},"asBuffer":null},"loaded":true}}
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<?php
 
// Staring straight up into the sky ... oh my my
error_reporting(-1);
mb_internal_encoding('utf-8');


//заканчиваем преобразование
function makeWordOfThree ($number,$femaleSpelling,$spelling) {
  $i = 0;
  //запускаем перебор для преобразования
  foreach ($number as $key => $value){
    $i++;
    $oneDig = floor($value / 100)*100;

    //работаем с сотнями
    if ($oneDig!=0) {
      $digName = $spelling[$oneDig];
    }else{
      $digName = "";
    }

    $oneDig = $value % 100;
    $oneDig = floor ($oneDig/10);

    // сохраняем десяток на для едениц
    $secondDig = $oneDig;


    //работаем с десятками и числами с 10 до 19
    if (($oneDig != 0)&&($oneDig > 1)){
      $oneDig = $oneDig * 10;
      $digName = $digName . " " . $spelling [$oneDig];
    }elseif ($oneDig == 0) {
      $digName .= "" ;
    }else{
      $oneDig = $value % 100;
      $digName = $digName . " " . $spelling[$oneDig];
    }

    
    $oneDig = $value % 10;

    //работаем с ед.
    if (($i == 2)&&(($oneDig == 1)|($oneDig == 2))&&($secondDig != 1)){
      $digName = $digName . " " . $femaleSpelling[$oneDig];
    }elseif (($secondDig != 1)&&($oneDig != 0)) {
      $digName = $digName . " " . $spelling[$oneDig];
    }else{
      $digName .= "";
    }
    
    $number[$key] = $digName;
  }


  return $number;
}

// делаем из ключей словесную загатовку
function makeWordOfKeys ($number,$currencyName) {
  $countThree = count($number);
  $nameKeys = [];
  if ((($number[0] % 100 >20)|($number[0] % 100 < 5))&&(($number[0] % 10 == 2)|($number[0] % 10 == 3 )|($number[0] % 10 == 4))) {
    $nameKeys [0] = $currencyName[2];
  }elseif (($number[0] % 10 == 1)&&($number[0] % 100 != 11)){
    $nameKeys [0] = $currencyName[1];
  }else{
    $nameKeys [0] = $currencyName[0];
  }

  if ($countThree >= 2) {
    if ((($number[1] % 100 >20)|($number[1] % 100 < 5))&&(($number[1] % 10 == 2)|($number[1] % 10 == 3 )|($number[1] % 10 == 4))) {
    $nameKeys [1] = $currencyName[5];
    }elseif  ($number[1] % 10 == 1){
    $nameKeys [1] = $currencyName[3];
    }else{
    $nameKeys [1] = $currencyName[4];
    }
  }
  
  if ($countThree >= 3){
    if ((($number[2] % 100 > 20)|($number[2] % 100 < 5))&&(($number[2] % 10 == 2)|($number[2] % 10 == 3 )|($number[2] % 10 == 4))) {
    $nameKeys [2] = $currencyName[7];
    }elseif ($number[1] % 10 == 1){
    $nameKeys [2] = $currencyName[6];
    }else{
    $nameKeys [2] = $currencyName[8];
    }
  }
 $number = array_combine($nameKeys,$number);

 return $number;

}

/* разбиваем на массив троек */
function makeThree($number) {
  $numerals = [];
  for ($i=0;1<=$number;$i++) {
    $numerals[$i] = $number % 1000;
    $number/=1000;
  }

  return $numerals;
  
}

//наводим красоту
function fixText($text){
  $text = trim($text);
  /*делаем первую букву заглавной*/
  $first = mb_substr($text,0,1);
  $first = mb_strtoupper($first);
  $text = mb_substr($text,1);
  $text = $first . $text;
  //пробелы
  $text = preg_replace("/[\s]+/ui"," ",$text);
  
  return $text;
}

//делаем основной функцией и всю работу передаем ей.
function convertNumbersToWords ($number) {
  $accountBalance = "";
  
  $spelling = array(
        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  =>  'девятнадцать'    
    );
 
  $femaleSpelling = array(
        1   =>  'одна',        2   =>  'две'
    );

  $currencyName = array(
      0   =>  'рублей',   
      1   =>  'рубль',   
      2   =>  'рубля',    
      3   =>  'тысяча',    
      4   =>  'тысяч', 
      5   =>  'тысячи',   
      6   =>  'миллион',  
      7   =>  'миллиона',   
      8   =>  'миллионов'
  );
  
  if ($number == 0){
    $accountBalance = "ноль рублей";
  }else{
    $number = makeThree($number);
    $number = makeWordOfKeys ($number,$currencyName);
    $number = makeWordOfThree ($number,$femaleSpelling,$spelling);
    foreach ($number as $key => $value){
    $accountBalance = $value . " " . $key ." " . $accountBalance . " ";
    }
  }
  $accountBalance = fixText($accountBalance);
  return $accountBalance;
}

 

 
/* Вызовем функцию несколько раз */
$amount1 = 212;
$test1 = convertNumbersToWords($amount1);
 
echo "На вашем счету: {$test1}.\n------------------------------------------------------------------------------------------------------------\n";
 
$amount2 = mt_rand(1,99999999);
$test2 = convertNumbersToWords($amount2);
 
echo "На вашем счету: {$test2}.\n------------------------------------------------------------------------------------------------------------\n";
 
$amount3 = mt_rand(1,99999999);
$test3 = convertNumbersToWords($amount3);
 
echo "На вашем счету: {$test3}.\n------------------------------------------------------------------------------------------------------------\n";
 
$amount4 = mt_rand(1,99999999);
$test4 = convertNumbersToWords($amount4);
 
echo "На вашем счету: {$test4}.\n------------------------------------------------------------------------------------------------------------\n";

?>
PHP 7.0.8 (Legacy: use the following for new features: Command-line PHP: https://repl.it/languages/php_cli PHP Web Server: https://repl.it/languages/php7