3v4l.org

run code in 300+ PHP versions simultaneously
<?php function createCompressedString($shorts) { $compressLen = $compressPos = $currentLen = $currentPos = 0; $inBlock = false; for ($i = 0; $i < 8; $i++) { if ($shorts[$i] === 0) { if (!$inBlock) { $inBlock = true; $currentPos = $i; } $currentLen++; } else if ($inBlock) { if ($currentLen > $compressLen) { $compressLen = $currentLen; $compressPos = $currentPos; } $inBlock = false; $currentPos = $currentLen = 0; } } if ($inBlock) { $compressLen = $currentLen; $compressPos = $currentPos; } if ($compressLen === 8) { return '::'; } if ($compressLen > 1) { if ($compressPos === 0 || $compressPos + $compressLen === 8) { array_splice($shorts, $compressPos, $compressLen, ['', '']); } } return implode(':', array_map(function($short) { return $short === '' ? '' : dechex($short); }, $shorts)); } var_dump(createCompressedString([1, 0, 0, 0, 1, 2001, 23234, 21]));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IZA2D
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'createcompressedstring'
          2        SEND_VAL                                                 <array>
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function createcompressedstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 8
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 34
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 48
Branch analysis from position: 36
2 jumps found. (Code = 47) Position 1 = 38, Position 2 = 41
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 48
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
Branch analysis from position: 41
Branch analysis from position: 48
Branch analysis from position: 31
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 8
Branch analysis from position: 28
Branch analysis from position: 8
Branch analysis from position: 15
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 25
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 8
Branch analysis from position: 28
Branch analysis from position: 8
Branch analysis from position: 22
Branch analysis from position: 25
filename:       /in/IZA2D
function name:  createCompressedString
number of ops:  59
compiled vars:  !0 = $shorts, !1 = $compressLen, !2 = $compressPos, !3 = $currentLen, !4 = $currentPos, !5 = $inBlock, !6 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                           ~7      !4, 0
          2        ASSIGN                                           ~8      !3, ~7
          3        ASSIGN                                           ~9      !2, ~8
          4        ASSIGN                                                   !1, ~9
    6     5        ASSIGN                                                   !5, <false>
    8     6        ASSIGN                                                   !6, 0
          7      > JMP                                                      ->26
    9     8    >   FETCH_DIM_R                                      ~13     !0, !6
          9        IS_IDENTICAL                                             ~13, 0
         10      > JMPZ                                                     ~14, ->17
   10    11    >   BOOL_NOT                                         ~15     !5
         12      > JMPZ                                                     ~15, ->15
   11    13    >   ASSIGN                                                   !5, <true>
   12    14        ASSIGN                                                   !4, !6
   15    15    >   PRE_INC                                                  !3
         16      > JMP                                                      ->25
   16    17    > > JMPZ                                                     !5, ->25
   17    18    >   IS_SMALLER                                               !1, !3
         19      > JMPZ                                                     ~19, ->22
   18    20    >   ASSIGN                                                   !1, !3
   19    21        ASSIGN                                                   !2, !4
   22    22    >   ASSIGN                                                   !5, <false>
   23    23        ASSIGN                                           ~23     !3, 0
         24        ASSIGN                                                   !4, ~23
    8    25    >   PRE_INC                                                  !6
         26    >   IS_SMALLER                                               !6, 8
         27      > JMPNZ                                                    ~26, ->8
   26    28    > > JMPZ                                                     !5, ->31
   27    29    >   ASSIGN                                                   !1, !3
   28    30        ASSIGN                                                   !2, !4
   31    31    >   IS_IDENTICAL                                             !1, 8
         32      > JMPZ                                                     ~29, ->34
   32    33    > > RETURN                                                   '%3A%3A'
   35    34    >   IS_SMALLER                                               1, !1
         35      > JMPZ                                                     ~30, ->48
   36    36    >   IS_IDENTICAL                                     ~31     !2, 0
         37      > JMPNZ_EX                                         ~31     ~31, ->41
         38    >   ADD                                              ~32     !2, !1
         39        IS_IDENTICAL                                     ~33     ~32, 8
         40        BOOL                                             ~31     ~33
         41    > > JMPZ                                                     ~31, ->48
   37    42    >   INIT_FCALL                                               'array_splice'
         43        SEND_REF                                                 !0
         44        SEND_VAR                                                 !2
         45        SEND_VAR                                                 !1
         46        SEND_VAL                                                 <array>
         47        DO_ICALL                                                 
   41    48    >   INIT_FCALL                                               'implode'
         49        SEND_VAL                                                 '%3A'
         50        INIT_FCALL                                               'array_map'
         51        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FIZA2D%3A41%240'
   43    52        SEND_VAL                                                 ~35
         53        SEND_VAR                                                 !0
         54        DO_ICALL                                         $36     
         55        SEND_VAR                                                 $36
         56        DO_ICALL                                         $37     
         57      > RETURN                                                   $37
   44    58*     > RETURN                                                   null

End of function createcompressedstring

Function %00%7Bclosure%7D%2Fin%2FIZA2D%3A41%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IZA2D
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $short
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   RECV                                             !0      
   42     1        IS_IDENTICAL                                             !0, ''
          2      > JMPZ                                                     ~1, ->5
          3    >   QM_ASSIGN                                        ~2      ''
          4      > JMP                                                      ->9
          5    >   INIT_FCALL                                               'dechex'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $3      
          8        QM_ASSIGN                                        ~2      $3
          9    > > RETURN                                                   ~2
   43    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FIZA2D%3A41%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.05 ms | 1407 KiB | 24 Q