3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calculateLevels( $total, $totalPerLevel = 2, $iteration = 0 ) { if( $total <= 1 ) { return $iteration; } else { if ( $totalPerLevel === 1 ) { $total--; } return calculateLevels( (int) ( $total / $totalPerLevel ), $totalPerLevel, $iteration + 1 ); } } $x = 15; echo "$x - " .calculateLevels( $x,2 ) . "\n"; $x = 15; echo "$x - " .calculateLevels( $x,5 ) . "\n"; $x = 15; echo "$x - " .calculateLevels( $x,3 ) . "\n"; $x = 15; echo "$x - " .calculateLevels( $x,1 ) . "\n"; $x = 15; echo "$x - " .calculateLevels( $x,8 ) . "\n"; $x = 15; echo "$x - " .calculateLevels( $x,20 ) . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rlDX2
function name:  (null)
number of ops:  61
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, 15
          1        NOP                                                      
          2        FAST_CONCAT                                      ~2      !0, '+-+'
          3        INIT_FCALL                                               'calculatelevels'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 2
          6        DO_FCALL                                      0  $3      
          7        CONCAT                                           ~4      ~2, $3
          8        CONCAT                                           ~5      ~4, '%0A'
          9        ECHO                                                     ~5
   18    10        ASSIGN                                                   !0, 15
         11        NOP                                                      
         12        FAST_CONCAT                                      ~7      !0, '+-+'
         13        INIT_FCALL                                               'calculatelevels'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 5
         16        DO_FCALL                                      0  $8      
         17        CONCAT                                           ~9      ~7, $8
         18        CONCAT                                           ~10     ~9, '%0A'
         19        ECHO                                                     ~10
   19    20        ASSIGN                                                   !0, 15
         21        NOP                                                      
         22        FAST_CONCAT                                      ~12     !0, '+-+'
         23        INIT_FCALL                                               'calculatelevels'
         24        SEND_VAR                                                 !0
         25        SEND_VAL                                                 3
         26        DO_FCALL                                      0  $13     
         27        CONCAT                                           ~14     ~12, $13
         28        CONCAT                                           ~15     ~14, '%0A'
         29        ECHO                                                     ~15
   20    30        ASSIGN                                                   !0, 15
         31        NOP                                                      
         32        FAST_CONCAT                                      ~17     !0, '+-+'
         33        INIT_FCALL                                               'calculatelevels'
         34        SEND_VAR                                                 !0
         35        SEND_VAL                                                 1
         36        DO_FCALL                                      0  $18     
         37        CONCAT                                           ~19     ~17, $18
         38        CONCAT                                           ~20     ~19, '%0A'
         39        ECHO                                                     ~20
   21    40        ASSIGN                                                   !0, 15
         41        NOP                                                      
         42        FAST_CONCAT                                      ~22     !0, '+-+'
         43        INIT_FCALL                                               'calculatelevels'
         44        SEND_VAR                                                 !0
         45        SEND_VAL                                                 8
         46        DO_FCALL                                      0  $23     
         47        CONCAT                                           ~24     ~22, $23
         48        CONCAT                                           ~25     ~24, '%0A'
         49        ECHO                                                     ~25
   22    50        ASSIGN                                                   !0, 15
         51        NOP                                                      
         52        FAST_CONCAT                                      ~27     !0, '+-+'
         53        INIT_FCALL                                               'calculatelevels'
         54        SEND_VAR                                                 !0
         55        SEND_VAL                                                 20
         56        DO_FCALL                                      0  $28     
         57        CONCAT                                           ~29     ~27, $28
         58        CONCAT                                           ~30     ~29, '%0A'
         59        ECHO                                                     ~30
         60      > RETURN                                                   1

Function calculatelevels:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/rlDX2
function name:  calculateLevels
number of ops:  20
compiled vars:  !0 = $total, !1 = $totalPerLevel, !2 = $iteration
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      2
          2        RECV_INIT                                        !2      0
    5     3        IS_SMALLER_OR_EQUAL                                      !0, 1
          4      > JMPZ                                                     ~3, ->7
    7     5    > > RETURN                                                   !2
          6*       JMP                                                      ->19
    9     7    >   IS_IDENTICAL                                             !1, 1
          8      > JMPZ                                                     ~4, ->10
   11     9    >   PRE_DEC                                                  !0
   13    10    >   INIT_FCALL_BY_NAME                                       'calculateLevels'
         11        DIV                                              ~6      !0, !1
         12        CAST                                          4  ~7      ~6
         13        SEND_VAL_EX                                              ~7
         14        SEND_VAR_EX                                              !1
         15        ADD                                              ~8      !2, 1
         16        SEND_VAL_EX                                              ~8
         17        DO_FCALL                                      0  $9      
         18      > RETURN                                                   $9
   15    19*     > RETURN                                                   null

End of function calculatelevels

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.83 ms | 1402 KiB | 19 Q