3v4l.org

run code in 300+ PHP versions simultaneously
<?php function encode($arr, $value) { $arr = array_values($arr); $out = []; $c = count($arr); while($value > 0) { array_unshift($out, $arr[$value%$c]); $value = ($value - $value%$c) / $c; } return $out; } var_dump(encode(range('0', '1'), 15));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PUXa3
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'encode'
          2        INIT_FCALL                                               'range'
          3        SEND_VAL                                                 '0'
          4        SEND_VAL                                                 '1'
          5        DO_ICALL                                         $0      
          6        SEND_VAR                                                 $0
          7        SEND_VAL                                                 15
          8        DO_FCALL                                      0  $1      
          9        SEND_VAR                                                 $1
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 10
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 10
Branch analysis from position: 22
Branch analysis from position: 10
filename:       /in/PUXa3
function name:  encode
number of ops:  24
compiled vars:  !0 = $arr, !1 = $value, !2 = $out, !3 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'array_values'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !0, $4
    5     6        ASSIGN                                                   !2, <array>
    6     7        COUNT                                            ~7      !0
          8        ASSIGN                                                   !3, ~7
    7     9      > JMP                                                      ->20
    8    10    >   INIT_FCALL                                               'array_unshift'
         11        SEND_REF                                                 !2
         12        MOD                                              ~9      !1, !3
         13        FETCH_DIM_R                                      ~10     !0, ~9
         14        SEND_VAL                                                 ~10
         15        DO_ICALL                                                 
    9    16        MOD                                              ~12     !1, !3
         17        SUB                                              ~13     !1, ~12
         18        DIV                                              ~14     ~13, !3
         19        ASSIGN                                                   !1, ~14
    7    20    >   IS_SMALLER                                               0, !1
         21      > JMPNZ                                                    ~16, ->10
   11    22    > > RETURN                                                   !2
   12    23*     > RETURN                                                   null

End of function encode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.36 ms | 1399 KiB | 22 Q