3v4l.org

run code in 300+ PHP versions simultaneously
<?php function num2word(int $num, array $words): string { $num = ($n = abs($num) % 100) > 19 ? $n % 10 : $n; switch ($num) { case 1: $w = $words[0]; break; case 2: case 3: case 4: $w = $words[1]; break; default: $w = $words[2]; break; } return $w; } echo num2word(23, ['рубль', 'рубля', 'рублей']).PHP_EOL; echo num2word(151, ['рубль', 'рубля', 'рублей']).PHP_EOL; echo num2word(556, ['рубль', 'рубля', 'рублей']).PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wh6ki
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'num2word'
          1        SEND_VAL                                                 23
          2        SEND_VAL                                                 <array>
          3        DO_FCALL                                      0  $0      
          4        CONCAT                                           ~1      $0, '%0A'
          5        ECHO                                                     ~1
   27     6        INIT_FCALL                                               'num2word'
          7        SEND_VAL                                                 151
          8        SEND_VAL                                                 <array>
          9        DO_FCALL                                      0  $2      
         10        CONCAT                                           ~3      $2, '%0A'
         11        ECHO                                                     ~3
   28    12        INIT_FCALL                                               'num2word'
         13        SEND_VAL                                                 556
         14        SEND_VAL                                                 <array>
         15        DO_FCALL                                      0  $4      
         16        CONCAT                                           ~5      $4, '%0A'
         17        ECHO                                                     ~5
   29    18      > RETURN                                                   1

Function num2word:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
6 jumps found. (Code = 187) Position 1 = 24, Position 2 = 27, Position 3 = 27, Position 4 = 27, Position 5 = 30, Position 6 = 15
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 27
Branch analysis from position: 27
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 24
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 27
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 27
Branch analysis from position: 27
Branch analysis from position: 27
Branch analysis from position: 24
Branch analysis from position: 12
6 jumps found. (Code = 187) Position 1 = 24, Position 2 = 27, Position 3 = 27, Position 4 = 27, Position 5 = 30, Position 6 = 15
Branch analysis from position: 24
Branch analysis from position: 27
Branch analysis from position: 27
Branch analysis from position: 27
Branch analysis from position: 30
Branch analysis from position: 15
filename:       /in/Wh6ki
function name:  num2word
number of ops:  37
compiled vars:  !0 = $num, !1 = $words, !2 = $n, !3 = $w
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'abs'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        MOD                                              ~5      $4, 100
          6        ASSIGN                                           ~6      !2, ~5
          7        IS_SMALLER                                               19, ~6
          8      > JMPZ                                                     ~7, ->12
          9    >   MOD                                              ~8      !2, 10
         10        QM_ASSIGN                                        ~9      ~8
         11      > JMP                                                      ->13
         12    >   QM_ASSIGN                                        ~9      !2
         13    >   ASSIGN                                                   !0, ~9
    7    14      > SWITCH_LONG                                              !0, [ 1:->24, 2:->27, 3:->27, 4:->27, ], ->30
    8    15    >   IS_EQUAL                                                 !0, 1
         16      > JMPNZ                                                    ~11, ->24
   12    17    >   IS_EQUAL                                                 !0, 2
         18      > JMPNZ                                                    ~11, ->27
   13    19    >   IS_EQUAL                                                 !0, 3
         20      > JMPNZ                                                    ~11, ->27
   14    21    >   IS_EQUAL                                                 !0, 4
         22      > JMPNZ                                                    ~11, ->27
         23    > > JMP                                                      ->30
    9    24    >   FETCH_DIM_R                                      ~12     !1, 0
         25        ASSIGN                                                   !3, ~12
   10    26      > JMP                                                      ->33
   15    27    >   FETCH_DIM_R                                      ~14     !1, 1
         28        ASSIGN                                                   !3, ~14
   16    29      > JMP                                                      ->33
   19    30    >   FETCH_DIM_R                                      ~16     !1, 2
         31        ASSIGN                                                   !3, ~16
   20    32      > JMP                                                      ->33
   23    33    >   VERIFY_RETURN_TYPE                                       !3
         34      > RETURN                                                   !3
   24    35*       VERIFY_RETURN_TYPE                                       
         36*     > RETURN                                                   null

End of function num2word

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.59 ms | 1009 KiB | 17 Q