3v4l.org

run code in 300+ PHP versions simultaneously
<?php function inclineWord($number, $word1, $word2, $word5) { if ($number % 100 >= 11 and $number % 100 <= 14) { return $word5; } elseif ($number % 10 == 1) { return $word1; } elseif ($number % 10 >= 2 and $number % 10 <= 4) { return $word2; } else return $word5; } function smallNumberToText($number, $isFemale) { $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 => 'две' ); $array = []; if ($number == 0) { return $spelling[$number]; } if ($number % 1000 >= 100 && $number % 1000 <= 999) { $array[] = $spelling[$number % 1000 - ($number % 1000 % 100)]; } if ($number % 100 >= 20 && $number % 100 <= 99) { $array[] = $spelling[$number % 100 - ($number % 100 % 10)]; } if ($number % 100 >= 10 && $number % 100 <= 19) { $array[] = $spelling[$number % 100]; } elseif ($isFemale == 0 && $number % 10 >= 1 && $number % 10 <= 9) { $array[] = $spelling[$number % 10]; } elseif ($isFemale == 1 && $number % 10 >= 1 && $number % 10 <= 2) { $array[] = $femaleSpelling[$number % 10]; } elseif ($isFemale == 1 && $number % 10 >= 3 && $number % 10 <= 9) { $array[] = $spelling[$number % 10]; } $result = implode(" ", $array); return $result; } function numberToText($number) { $array = []; if (floor($number / 1000000) > 0) { $array[] = smallNumberToText(floor($number / 1000000), 0) . inclineWord(floor($number / 1000000), " миллион", " миллиона", " миллионов"); } if (floor($number / 1000) > 0) { $array[] = smallNumberToText(floor($number / 1000), 1) . inclineWord(floor($number / 1000), " тысяча", " тысячи", " тысяч"); } if ($number > 0) { $array[] = smallNumberToText($number % 1000, 0) . inclineWord($number % 1000, " рубль", " рубля", " рублей"); } $result = implode(" ", $array); return $result; } $a = numberToText(120000); echo $a;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mVg0n
function name:  (null)
number of ops:  6
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   72     0  E >   INIT_FCALL                                               'numbertotext'
          1        SEND_VAL                                                 120000
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   73     4        ECHO                                                     !0
   74     5      > RETURN                                                   1

Function inclineword:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 10
filename:       /in/mVg0n
function name:  inclineWord
number of ops:  29
compiled vars:  !0 = $number, !1 = $word1, !2 = $word2, !3 = $word5
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    5     4        MOD                                              ~4      !0, 100
          5        IS_SMALLER_OR_EQUAL                              ~5      11, ~4
          6      > JMPZ_EX                                          ~5      ~5, ->10
          7    >   MOD                                              ~6      !0, 100
          8        IS_SMALLER_OR_EQUAL                              ~7      ~6, 14
          9        BOOL                                             ~5      ~7
         10    > > JMPZ                                                     ~5, ->13
    6    11    > > RETURN                                                   !3
         12*       JMP                                                      ->28
    7    13    >   MOD                                              ~8      !0, 10
         14        IS_EQUAL                                                 ~8, 1
         15      > JMPZ                                                     ~9, ->18
    8    16    > > RETURN                                                   !1
         17*       JMP                                                      ->28
    9    18    >   MOD                                              ~10     !0, 10
         19        IS_SMALLER_OR_EQUAL                              ~11     2, ~10
         20      > JMPZ_EX                                          ~11     ~11, ->24
         21    >   MOD                                              ~12     !0, 10
         22        IS_SMALLER_OR_EQUAL                              ~13     ~12, 4
         23        BOOL                                             ~11     ~13
         24    > > JMPZ                                                     ~11, ->27
   10    25    > > RETURN                                                   !2
         26*       JMP                                                      ->28
   12    27    > > RETURN                                                   !3
   13    28*     > RETURN                                                   null

End of function inclineword

Function smallnumbertotext:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
2 jumps found. (Code = 46) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 37
Branch analysis from position: 30
2 jumps found. (Code = 46) Position 1 = 40, Position 2 = 43
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 49
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 93
Branch analysis from position: 93
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
2 jumps found. (Code = 46) Position 1 = 51, Position 2 = 54
Branch analysis from position: 51
2 jumps found. (Code = 46) Position 1 = 55, Position 2 = 58
Branch analysis from position: 55
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 64
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 93
Branch analysis from position: 93
Branch analysis from position: 64
2 jumps found. (Code = 46) Position 1 = 66, Position 2 = 69
Branch analysis from position: 66
2 jumps found. (Code = 46) Position 1 = 70, Position 2 = 73
Branch analysis from position: 70
2 jumps found. (Code = 43) Position 1 = 74, Position 2 = 79
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 93
Branch analysis from position: 93
Branch analysis from position: 79
2 jumps found. (Code = 46) Position 1 = 81, Position 2 = 84
Branch analysis from position: 81
2 jumps found. (Code = 46) Position 1 = 85, Position 2 = 88
Branch analysis from position: 85
2 jumps found. (Code = 43) Position 1 = 89, Position 2 = 93
Branch analysis from position: 89
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 93
Branch analysis from position: 88
Branch analysis from position: 84
Branch analysis from position: 73
Branch analysis from position: 69
Branch analysis from position: 58
Branch analysis from position: 54
Branch analysis from position: 43
Branch analysis from position: 37
Branch analysis from position: 29
Branch analysis from position: 23
Branch analysis from position: 15
filename:       /in/mVg0n
function name:  smallNumberToText
number of ops:  100
compiled vars:  !0 = $number, !1 = $isFemale, !2 = $spelling, !3 = $femaleSpelling, !4 = $array, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        ASSIGN                                                   !2, <array>
   29     3        ASSIGN                                                   !3, <array>
   32     4        ASSIGN                                                   !4, <array>
   33     5        IS_EQUAL                                                 !0, 0
          6      > JMPZ                                                     ~9, ->9
   34     7    >   FETCH_DIM_R                                      ~10     !2, !0
          8      > RETURN                                                   ~10
   36     9    >   MOD                                              ~11     !0, 1000
         10        IS_SMALLER_OR_EQUAL                              ~12     100, ~11
         11      > JMPZ_EX                                          ~12     ~12, ->15
         12    >   MOD                                              ~13     !0, 1000
         13        IS_SMALLER_OR_EQUAL                              ~14     ~13, 999
         14        BOOL                                             ~12     ~14
         15    > > JMPZ                                                     ~12, ->23
   37    16    >   MOD                                              ~16     !0, 1000
         17        MOD                                              ~17     !0, 1000
         18        MOD                                              ~18     ~17, 100
         19        SUB                                              ~19     ~16, ~18
         20        FETCH_DIM_R                                      ~20     !2, ~19
         21        ASSIGN_DIM                                               !4
         22        OP_DATA                                                  ~20
   39    23    >   MOD                                              ~21     !0, 100
         24        IS_SMALLER_OR_EQUAL                              ~22     20, ~21
         25      > JMPZ_EX                                          ~22     ~22, ->29
         26    >   MOD                                              ~23     !0, 100
         27        IS_SMALLER_OR_EQUAL                              ~24     ~23, 99
         28        BOOL                                             ~22     ~24
         29    > > JMPZ                                                     ~22, ->37
   40    30    >   MOD                                              ~26     !0, 100
         31        MOD                                              ~27     !0, 100
         32        MOD                                              ~28     ~27, 10
         33        SUB                                              ~29     ~26, ~28
         34        FETCH_DIM_R                                      ~30     !2, ~29
         35        ASSIGN_DIM                                               !4
         36        OP_DATA                                                  ~30
   42    37    >   MOD                                              ~31     !0, 100
         38        IS_SMALLER_OR_EQUAL                              ~32     10, ~31
         39      > JMPZ_EX                                          ~32     ~32, ->43
         40    >   MOD                                              ~33     !0, 100
         41        IS_SMALLER_OR_EQUAL                              ~34     ~33, 19
         42        BOOL                                             ~32     ~34
         43    > > JMPZ                                                     ~32, ->49
   43    44    >   MOD                                              ~36     !0, 100
         45        FETCH_DIM_R                                      ~37     !2, ~36
         46        ASSIGN_DIM                                               !4
         47        OP_DATA                                                  ~37
         48      > JMP                                                      ->93
   44    49    >   IS_EQUAL                                         ~38     !1, 0
         50      > JMPZ_EX                                          ~38     ~38, ->54
         51    >   MOD                                              ~39     !0, 10
         52        IS_SMALLER_OR_EQUAL                              ~40     1, ~39
         53        BOOL                                             ~38     ~40
         54    > > JMPZ_EX                                          ~38     ~38, ->58
         55    >   MOD                                              ~41     !0, 10
         56        IS_SMALLER_OR_EQUAL                              ~42     ~41, 9
         57        BOOL                                             ~38     ~42
         58    > > JMPZ                                                     ~38, ->64
   45    59    >   MOD                                              ~44     !0, 10
         60        FETCH_DIM_R                                      ~45     !2, ~44
         61        ASSIGN_DIM                                               !4
         62        OP_DATA                                                  ~45
         63      > JMP                                                      ->93
   46    64    >   IS_EQUAL                                         ~46     !1, 1
         65      > JMPZ_EX                                          ~46     ~46, ->69
         66    >   MOD                                              ~47     !0, 10
         67        IS_SMALLER_OR_EQUAL                              ~48     1, ~47
         68        BOOL                                             ~46     ~48
         69    > > JMPZ_EX                                          ~46     ~46, ->73
         70    >   MOD                                              ~49     !0, 10
         71        IS_SMALLER_OR_EQUAL                              ~50     ~49, 2
         72        BOOL                                             ~46     ~50
         73    > > JMPZ                                                     ~46, ->79
   47    74    >   MOD                                              ~52     !0, 10
         75        FETCH_DIM_R                                      ~53     !3, ~52
         76        ASSIGN_DIM                                               !4
         77        OP_DATA                                                  ~53
         78      > JMP                                                      ->93
   48    79    >   IS_EQUAL                                         ~54     !1, 1
         80      > JMPZ_EX                                          ~54     ~54, ->84
         81    >   MOD                                              ~55     !0, 10
         82        IS_SMALLER_OR_EQUAL                              ~56     3, ~55
         83        BOOL                                             ~54     ~56
         84    > > JMPZ_EX                                          ~54     ~54, ->88
         85    >   MOD                                              ~57     !0, 10
         86        IS_SMALLER_OR_EQUAL                              ~58     ~57, 9
         87        BOOL                                             ~54     ~58
         88    > > JMPZ                                                     ~54, ->93
   49    89    >   MOD                                              ~60     !0, 10
         90        FETCH_DIM_R                                      ~61     !2, ~60
         91        ASSIGN_DIM                                               !4
         92        OP_DATA                                                  ~61
   52    93    >   INIT_FCALL                                               'implode'
         94        SEND_VAL                                                 '+'
         95        SEND_VAR                                                 !4
         96        DO_ICALL                                         $62     
         97        ASSIGN                                                   !5, $62
   53    98      > RETURN                                                   !5
   54    99*     > RETURN                                                   null

End of function smallnumbertotext

Function numbertotext:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 29
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 56
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 73
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 73
Branch analysis from position: 56
Branch analysis from position: 29
filename:       /in/mVg0n
function name:  numberToText
number of ops:  80
compiled vars:  !0 = $number, !1 = $array, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   RECV                                             !0      
   58     1        ASSIGN                                                   !1, <array>
   59     2        INIT_FCALL                                               'floor'
          3        DIV                                              ~4      !0, 1000000
          4        SEND_VAL                                                 ~4
          5        DO_ICALL                                         $5      
          6        IS_SMALLER                                               0, $5
          7      > JMPZ                                                     ~6, ->29
   60     8    >   INIT_FCALL                                               'smallnumbertotext'
          9        INIT_FCALL                                               'floor'
         10        DIV                                              ~8      !0, 1000000
         11        SEND_VAL                                                 ~8
         12        DO_ICALL                                         $9      
         13        SEND_VAR                                                 $9
         14        SEND_VAL                                                 0
         15        DO_FCALL                                      0  $10     
         16        INIT_FCALL                                               'inclineword'
         17        INIT_FCALL                                               'floor'
         18        DIV                                              ~11     !0, 1000000
         19        SEND_VAL                                                 ~11
         20        DO_ICALL                                         $12     
         21        SEND_VAR                                                 $12
         22        SEND_VAL                                                 '+%D0%BC%D0%B8%D0%BB%D0%BB%D0%B8%D0%BE%D0%BD'
         23        SEND_VAL                                                 '+%D0%BC%D0%B8%D0%BB%D0%BB%D0%B8%D0%BE%D0%BD%D0%B0'
         24        SEND_VAL                                                 '+%D0%BC%D0%B8%D0%BB%D0%BB%D0%B8%D0%BE%D0%BD%D0%BE%D0%B2'
         25        DO_FCALL                                      0  $13     
         26        CONCAT                                           ~14     $10, $13
         27        ASSIGN_DIM                                               !1
         28        OP_DATA                                                  ~14
   62    29    >   INIT_FCALL                                               'floor'
         30        DIV                                              ~15     !0, 1000
         31        SEND_VAL                                                 ~15
         32        DO_ICALL                                         $16     
         33        IS_SMALLER                                               0, $16
         34      > JMPZ                                                     ~17, ->56
   63    35    >   INIT_FCALL                                               'smallnumbertotext'
         36        INIT_FCALL                                               'floor'
         37        DIV                                              ~19     !0, 1000
         38        SEND_VAL                                                 ~19
         39        DO_ICALL                                         $20     
         40        SEND_VAR                                                 $20
         41        SEND_VAL                                                 1
         42        DO_FCALL                                      0  $21     
         43        INIT_FCALL                                               'inclineword'
         44        INIT_FCALL                                               'floor'
         45        DIV                                              ~22     !0, 1000
         46        SEND_VAL                                                 ~22
         47        DO_ICALL                                         $23     
         48        SEND_VAR                                                 $23
         49        SEND_VAL                                                 '+%D1%82%D1%8B%D1%81%D1%8F%D1%87%D0%B0'
         50        SEND_VAL                                                 '+%D1%82%D1%8B%D1%81%D1%8F%D1%87%D0%B8'
         51        SEND_VAL                                                 '+%D1%82%D1%8B%D1%81%D1%8F%D1%87'
         52        DO_FCALL                                      0  $24     
         53        CONCAT                                           ~25     $21, $24
         54        ASSIGN_DIM                                               !1
         55        OP_DATA                                                  ~25
   65    56    >   IS_SMALLER                                               0, !0
         57      > JMPZ                                                     ~26, ->73
   66    58    >   INIT_FCALL                                               'smallnumbertotext'
         59        MOD                                              ~28     !0, 1000
         60        SEND_VAL                                                 ~28
         61        SEND_VAL                                                 0
         62        DO_FCALL                                      0  $29     
         63        INIT_FCALL                                               'inclineword'
         64        MOD                                              ~30     !0, 1000
         65        SEND_VAL                                                 ~30
         66        SEND_VAL                                                 '+%D1%80%D1%83%D0%B1%D0%BB%D1%8C'
         67        SEND_VAL                                                 '+%D1%80%D1%83%D0%B1%D0%BB%D1%8F'
         68        SEND_VAL                                                 '+%D1%80%D1%83%D0%B1%D0%BB%D0%B5%D0%B9'
         69        DO_FCALL                                      0  $31     
         70        CONCAT                                           ~32     $29, $31
         71        ASSIGN_DIM                                               !1
         72        OP_DATA                                                  ~32
   68    73    >   INIT_FCALL                                               'implode'
         74        SEND_VAL                                                 '+'
         75        SEND_VAR                                                 !1
         76        DO_ICALL                                         $33     
         77        ASSIGN                                                   !2, $33
   69    78      > RETURN                                                   !2
   70    79*     > RETURN                                                   null

End of function numbertotext

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.64 ms | 1423 KiB | 24 Q