3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ConverToRoman(int $n){ $romanNumber_Array = 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); $res = ''; foreach ($romanNumber_Array as $roman => $number) { $res .= str_repeat($roman, (int) ($n / $number)); $n %= $number; } return $res; } echo ConverToRoman(3333); echo "\n---\n"; echo ConverToRoman(5000);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LgGaj
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'convertoroman'
          1        SEND_VAL                                                 3333
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   28     4        ECHO                                                     '%0A---%0A'
   29     5        INIT_FCALL                                               'convertoroman'
          6        SEND_VAL                                                 5000
          7        DO_FCALL                                      0  $1      
          8        ECHO                                                     $1
          9      > RETURN                                                   1

Function convertoroman:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/LgGaj
function name:  ConverToRoman
number of ops:  18
compiled vars:  !0 = $n, !1 = $romanNumber_Array, !2 = $res, !3 = $number, !4 = $roman
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
   19     2        ASSIGN                                                   !2, ''
   20     3      > FE_RESET_R                                       $7      !1, ->15
          4    > > FE_FETCH_R                                       ~8      $7, !3, ->15
          5    >   ASSIGN                                                   !4, ~8
   21     6        INIT_FCALL                                               'str_repeat'
          7        SEND_VAR                                                 !4
          8        DIV                                              ~10     !0, !3
          9        CAST                                          4  ~11     ~10
         10        SEND_VAL                                                 ~11
         11        DO_ICALL                                         $12     
         12        ASSIGN_OP                                     8          !2, $12
   22    13        ASSIGN_OP                                     5          !0, !3
   20    14      > JMP                                                      ->4
         15    >   FE_FREE                                                  $7
   24    16      > RETURN                                                   !2
   25    17*     > RETURN                                                   null

End of function convertoroman

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.52 ms | 1013 KiB | 16 Q