3v4l.org

run code in 300+ PHP versions simultaneously
<?php $address = '2001:db8::567:89ab'; $parts = explode(':', $address); $len = count($parts); if ($len < 8) { if ($parts[0] === '') { array_splice($parts, 0, 0, array_fill(0, 8 - $len, 0)); $parts = array_reverse($parts); } else { $parts = array_reverse($parts); if ($parts[0] === '') { array_splice($parts, 0, 0, array_fill(0, 8 - $len, 0)); } else { array_splice($parts, array_search('', $parts), 0, array_fill(0, 8 - $len, 0)); } } } $nibbles = []; $hex = '0123456789abcdef'; foreach (array_map('hexdec', $parts) as $part) { array_push( $nibbles, $hex[($part & 0xF000) >> 12], $hex[($part & 0x0F00) >> 8], $hex[($part & 0x00F0) >> 4], $hex[$part & 0x000F] ); } echo implode('.', $nibbles);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 66
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 30
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
2 jumps found. (Code = 77) Position 1 = 73, Position 2 = 93
Branch analysis from position: 73
2 jumps found. (Code = 78) Position 1 = 74, Position 2 = 93
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
Branch analysis from position: 93
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 93
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 50
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
Branch analysis from position: 50
2 jumps found. (Code = 77) Position 1 = 73, Position 2 = 93
Branch analysis from position: 73
Branch analysis from position: 93
Branch analysis from position: 66
filename:       /in/JtbRm
function name:  (null)
number of ops:  100
compiled vars:  !0 = $address, !1 = $parts, !2 = $len, !3 = $nibbles, !4 = $hex, !5 = $part
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '2001%3Adb8%3A%3A567%3A89ab'
    5     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%3A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !1, $7
    6     6        COUNT                                            ~9      !1
          7        ASSIGN                                                   !2, ~9
    8     8        IS_SMALLER                                               !2, 8
          9      > JMPZ                                                     ~11, ->66
    9    10    >   FETCH_DIM_R                                      ~12     !1, 0
         11        IS_IDENTICAL                                             ~12, ''
         12      > JMPZ                                                     ~13, ->30
   10    13    >   INIT_FCALL                                               'array_splice'
         14        SEND_REF                                                 !1
         15        SEND_VAL                                                 0
         16        SEND_VAL                                                 0
         17        INIT_FCALL                                               'array_fill'
         18        SEND_VAL                                                 0
         19        SUB                                              ~14     8, !2
         20        SEND_VAL                                                 ~14
         21        SEND_VAL                                                 0
         22        DO_ICALL                                         $15     
         23        SEND_VAR                                                 $15
         24        DO_ICALL                                                 
   11    25        INIT_FCALL                                               'array_reverse'
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                         $17     
         28        ASSIGN                                                   !1, $17
         29      > JMP                                                      ->66
   13    30    >   INIT_FCALL                                               'array_reverse'
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                         $19     
         33        ASSIGN                                                   !1, $19
   14    34        FETCH_DIM_R                                      ~21     !1, 0
         35        IS_IDENTICAL                                             ~21, ''
         36      > JMPZ                                                     ~22, ->50
   15    37    >   INIT_FCALL                                               'array_splice'
         38        SEND_REF                                                 !1
         39        SEND_VAL                                                 0
         40        SEND_VAL                                                 0
         41        INIT_FCALL                                               'array_fill'
         42        SEND_VAL                                                 0
         43        SUB                                              ~23     8, !2
         44        SEND_VAL                                                 ~23
         45        SEND_VAL                                                 0
         46        DO_ICALL                                         $24     
         47        SEND_VAR                                                 $24
         48        DO_ICALL                                                 
         49      > JMP                                                      ->66
   17    50    >   INIT_FCALL                                               'array_splice'
         51        SEND_REF                                                 !1
         52        INIT_FCALL                                               'array_search'
         53        SEND_VAL                                                 ''
         54        SEND_VAR                                                 !1
         55        DO_ICALL                                         $26     
         56        SEND_VAR                                                 $26
         57        SEND_VAL                                                 0
         58        INIT_FCALL                                               'array_fill'
         59        SEND_VAL                                                 0
         60        SUB                                              ~27     8, !2
         61        SEND_VAL                                                 ~27
         62        SEND_VAL                                                 0
         63        DO_ICALL                                         $28     
         64        SEND_VAR                                                 $28
         65        DO_ICALL                                                 
   22    66    >   ASSIGN                                                   !3, <array>
   23    67        ASSIGN                                                   !4, '0123456789abcdef'
   24    68        INIT_FCALL                                               'array_map'
         69        SEND_VAL                                                 'hexdec'
         70        SEND_VAR                                                 !1
         71        DO_ICALL                                         $32     
         72      > FE_RESET_R                                       $33     $32, ->93
         73    > > FE_FETCH_R                                               $33, !5, ->93
   25    74    >   INIT_FCALL                                               'array_push'
   26    75        SEND_REF                                                 !3
   27    76        BW_AND                                           ~34     !5, 61440
         77        SR                                               ~35     ~34, 12
         78        FETCH_DIM_R                                      ~36     !4, ~35
         79        SEND_VAL                                                 ~36
   28    80        BW_AND                                           ~37     !5, 3840
         81        SR                                               ~38     ~37, 8
         82        FETCH_DIM_R                                      ~39     !4, ~38
         83        SEND_VAL                                                 ~39
   29    84        BW_AND                                           ~40     !5, 240
         85        SR                                               ~41     ~40, 4
         86        FETCH_DIM_R                                      ~42     !4, ~41
         87        SEND_VAL                                                 ~42
   30    88        BW_AND                                           ~43     !5, 15
         89        FETCH_DIM_R                                      ~44     !4, ~43
         90        SEND_VAL                                                 ~44
         91        DO_ICALL                                                 
   24    92      > JMP                                                      ->73
         93    >   FE_FREE                                                  $33
   34    94        INIT_FCALL                                               'implode'
         95        SEND_VAL                                                 '.'
         96        SEND_VAR                                                 !3
         97        DO_ICALL                                         $46     
         98        ECHO                                                     $46
         99      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.23 ms | 1404 KiB | 29 Q