3v4l.org

run code in 300+ PHP versions simultaneously
<?php function numberToRoman($decimalNumber) { static $romanSymbolsMap = array('M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1); $result = ''; foreach ($romanSymbolsMap as $roman => $decimal) { if ($decimalNumber >= $decimal) { $result .= str_repeat($roman, $decimalNumber / $decimal); $decimalNumber %= $decimal; } } return $result; } for ($i=1; $i < 5000;$i++){ numberToRoman($i); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 2
Branch analysis from position: 8
Branch analysis from position: 2
filename:       /in/FMOeV
function name:  (null)
number of ops:  9
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   ASSIGN                                                   !0, 1
          1      > JMP                                                      ->6
   26     2    >   INIT_FCALL                                               'numbertoroman'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0          
   25     5        PRE_INC                                                  !0
          6    >   IS_SMALLER                                               !0, 5000
          7      > JMPNZ                                                    ~4, ->2
   27     8    > > RETURN                                                   1

Function numbertoroman:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 16
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 15
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/FMOeV
function name:  numberToRoman
number of ops:  19
compiled vars:  !0 = $decimalNumber, !1 = $romanSymbolsMap, !2 = $result, !3 = $decimal, !4 = $roman
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   RECV                                             !0      
    3     1        BIND_STATIC                                              !1
   12     2        ASSIGN                                                   !2, ''
   14     3      > FE_RESET_R                                       $6      !1, ->16
          4    > > FE_FETCH_R                                       ~7      $6, !3, ->16
          5    >   ASSIGN                                                   !4, ~7
   15     6        IS_SMALLER_OR_EQUAL                                      !3, !0
          7      > JMPZ                                                     ~9, ->15
   16     8    >   INIT_FCALL                                               'str_repeat'
          9        SEND_VAR                                                 !4
         10        DIV                                              ~10     !0, !3
         11        SEND_VAL                                                 ~10
         12        DO_ICALL                                         $11     
         13        ASSIGN_OP                                     8          !2, $11
   17    14        ASSIGN_OP                                     5          !0, !3
   14    15    > > JMP                                                      ->4
         16    >   FE_FREE                                                  $6
   21    17      > RETURN                                                   !2
   22    18*     > RETURN                                                   null

End of function numbertoroman

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.06 ms | 1398 KiB | 16 Q