3v4l.org

run code in 300+ PHP versions simultaneously
<?php function _hex2bin($hex) { $hex = strtoupper($hex); $hexLen = strlen($hex); $bin = []; for ($i = 0; $i < $hexLen; $i++) { $char = $hex[$i]; if ($char == '0') $bin[] = "0000"; else if ($char == '1') $bin[] = "0001"; else if ($char == '2') $bin[] = "0010"; else if ($char == '3') $bin[] = "0011"; else if ($char == '4') $bin[] = "0100"; else if ($char == '5') $bin[] = "0101"; else if ($char == '6') $bin[] = "0110"; else if ($char == '7') $bin[] = "0111"; else if ($char == '8') $bin[] = "1000"; else if ($char == '9') $bin[] = "1001"; else if ($char == 'A') $bin[] = "1010"; else if ($char == 'B') $bin[] = "1011"; else if ($char == 'C') $bin[] = "1100"; else if ($char == 'D') $bin[] = "1101"; else if ($char == 'E') $bin[] = "1110"; else if ($char == 'F') $bin[] = "1111"; else $bin[] = "0000"; } return implode("", $bin); } echo _hex2bin("152F302436152F302435152F302434152F302433152F302433");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IkRmG
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   INIT_FCALL                                               '_hex2bin'
          1        SEND_VAL                                                 '152F302436152F302435152F302434152F302433152F302433'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function _hex2bin:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 95
Branch analysis from position: 95
2 jumps found. (Code = 44) Position 1 = 97, Position 2 = 10
Branch analysis from position: 97
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
2 jumps found. (Code = 44) Position 1 = 97, Position 2 = 10
Branch analysis from position: 97
Branch analysis from position: 10
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 32
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 37
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 42
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 47
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 52
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 57
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 62
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 62
2 jumps found. (Code = 43) Position 1 = 64, Position 2 = 67
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 67
2 jumps found. (Code = 43) Position 1 = 69, Position 2 = 72
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 72
2 jumps found. (Code = 43) Position 1 = 74, Position 2 = 77
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 77
2 jumps found. (Code = 43) Position 1 = 79, Position 2 = 82
Branch analysis from position: 79
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 82
2 jumps found. (Code = 43) Position 1 = 84, Position 2 = 87
Branch analysis from position: 84
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 87
2 jumps found. (Code = 43) Position 1 = 89, Position 2 = 92
Branch analysis from position: 89
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 92
2 jumps found. (Code = 44) Position 1 = 97, Position 2 = 10
Branch analysis from position: 97
Branch analysis from position: 10
filename:       /in/IkRmG
function name:  _hex2bin
number of ops:  103
compiled vars:  !0 = $hex, !1 = $hexLen, !2 = $bin, !3 = $i, !4 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'strtoupper'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $5      
          4        ASSIGN                                                   !0, $5
    6     5        STRLEN                                           ~7      !0
          6        ASSIGN                                                   !1, ~7
    7     7        ASSIGN                                                   !2, <array>
    8     8        ASSIGN                                                   !3, 0
          9      > JMP                                                      ->95
    9    10    >   FETCH_DIM_R                                      ~11     !0, !3
         11        ASSIGN                                                   !4, ~11
   10    12        IS_EQUAL                                                 !4, '0'
         13      > JMPZ                                                     ~13, ->17
         14    >   ASSIGN_DIM                                               !2
         15        OP_DATA                                                  '0000'
         16      > JMP                                                      ->94
   11    17    >   IS_EQUAL                                                 !4, '1'
         18      > JMPZ                                                     ~15, ->22
         19    >   ASSIGN_DIM                                               !2
         20        OP_DATA                                                  '0001'
         21      > JMP                                                      ->94
   12    22    >   IS_EQUAL                                                 !4, '2'
         23      > JMPZ                                                     ~17, ->27
         24    >   ASSIGN_DIM                                               !2
         25        OP_DATA                                                  '0010'
         26      > JMP                                                      ->94
   13    27    >   IS_EQUAL                                                 !4, '3'
         28      > JMPZ                                                     ~19, ->32
         29    >   ASSIGN_DIM                                               !2
         30        OP_DATA                                                  '0011'
         31      > JMP                                                      ->94
   14    32    >   IS_EQUAL                                                 !4, '4'
         33      > JMPZ                                                     ~21, ->37
         34    >   ASSIGN_DIM                                               !2
         35        OP_DATA                                                  '0100'
         36      > JMP                                                      ->94
   15    37    >   IS_EQUAL                                                 !4, '5'
         38      > JMPZ                                                     ~23, ->42
         39    >   ASSIGN_DIM                                               !2
         40        OP_DATA                                                  '0101'
         41      > JMP                                                      ->94
   16    42    >   IS_EQUAL                                                 !4, '6'
         43      > JMPZ                                                     ~25, ->47
         44    >   ASSIGN_DIM                                               !2
         45        OP_DATA                                                  '0110'
         46      > JMP                                                      ->94
   17    47    >   IS_EQUAL                                                 !4, '7'
         48      > JMPZ                                                     ~27, ->52
         49    >   ASSIGN_DIM                                               !2
         50        OP_DATA                                                  '0111'
         51      > JMP                                                      ->94
   18    52    >   IS_EQUAL                                                 !4, '8'
         53      > JMPZ                                                     ~29, ->57
         54    >   ASSIGN_DIM                                               !2
         55        OP_DATA                                                  '1000'
         56      > JMP                                                      ->94
   19    57    >   IS_EQUAL                                                 !4, '9'
         58      > JMPZ                                                     ~31, ->62
         59    >   ASSIGN_DIM                                               !2
         60        OP_DATA                                                  '1001'
         61      > JMP                                                      ->94
   20    62    >   IS_EQUAL                                                 !4, 'A'
         63      > JMPZ                                                     ~33, ->67
         64    >   ASSIGN_DIM                                               !2
         65        OP_DATA                                                  '1010'
         66      > JMP                                                      ->94
   21    67    >   IS_EQUAL                                                 !4, 'B'
         68      > JMPZ                                                     ~35, ->72
         69    >   ASSIGN_DIM                                               !2
         70        OP_DATA                                                  '1011'
         71      > JMP                                                      ->94
   22    72    >   IS_EQUAL                                                 !4, 'C'
         73      > JMPZ                                                     ~37, ->77
         74    >   ASSIGN_DIM                                               !2
         75        OP_DATA                                                  '1100'
         76      > JMP                                                      ->94
   23    77    >   IS_EQUAL                                                 !4, 'D'
         78      > JMPZ                                                     ~39, ->82
         79    >   ASSIGN_DIM                                               !2
         80        OP_DATA                                                  '1101'
         81      > JMP                                                      ->94
   24    82    >   IS_EQUAL                                                 !4, 'E'
         83      > JMPZ                                                     ~41, ->87
         84    >   ASSIGN_DIM                                               !2
         85        OP_DATA                                                  '1110'
         86      > JMP                                                      ->94
   25    87    >   IS_EQUAL                                                 !4, 'F'
         88      > JMPZ                                                     ~43, ->92
         89    >   ASSIGN_DIM                                               !2
         90        OP_DATA                                                  '1111'
         91      > JMP                                                      ->94
   26    92    >   ASSIGN_DIM                                               !2
         93        OP_DATA                                                  '0000'
    8    94    >   PRE_INC                                                  !3
         95    >   IS_SMALLER                                               !3, !1
         96      > JMPNZ                                                    ~47, ->10
   29    97    >   INIT_FCALL                                               'implode'
         98        SEND_VAL                                                 ''
         99        SEND_VAR                                                 !2
        100        DO_ICALL                                         $48     
        101      > RETURN                                                   $48
   30   102*     > RETURN                                                   null

End of function _hex2bin

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.98 ms | 958 KiB | 19 Q