3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = range('A', 'I'); $array2 = array(0 => 'A', 1 => 'B', 7 => 'H', 8 => 'I'); $size1 = count($array1); $size2 = count($array2); $hit = 0; $miss = -1; $min_size = min($size1, $size2); $array3 = array(); for($i = 0; $i < $min_size ;$i++) { $flag = 0; if(isset($array1[$i]) && isset($array2[$i])) { echo "set"; if($array1[$i] === $array2[$i]) { $hit++; echo "hit $i\n"; $miss = -1; } else $flag = 1; } else { $flag = 1; } if($flag == 1) { if($miss == -1) { if($hit > 0); array_push($array3, $hit); $miss = 0; array_push($array3, 0); } $hit = 0; } } if($hit > 0) array_push($array3, $hit); if($size1 != $size2) { if($miss == -1) array_push($array3,0); //Suppose array sizes are not equal and last scanned element-pair is not matched. To avoid an additional 0 } print_r($array3);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 20
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 66
Branch analysis from position: 62
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 74
Branch analysis from position: 68
2 jumps found. (Code = 43) Position 1 = 70, Position 2 = 74
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 74
Branch analysis from position: 74
Branch analysis from position: 66
Branch analysis from position: 20
2 jumps found. (Code = 46) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 40
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 38
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 57
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 56
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 47
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 20
Branch analysis from position: 60
Branch analysis from position: 20
Branch analysis from position: 47
Branch analysis from position: 56
Branch analysis from position: 57
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 57
Branch analysis from position: 43
Branch analysis from position: 57
Branch analysis from position: 25
filename:       /in/147Ml
function name:  (null)
number of ops:  78
compiled vars:  !0 = $array1, !1 = $array2, !2 = $size1, !3 = $size2, !4 = $hit, !5 = $miss, !6 = $min_size, !7 = $array3, !8 = $i, !9 = $flag
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 'A'
          2        SEND_VAL                                                 'I'
          3        DO_ICALL                                         $10     
          4        ASSIGN                                                   !0, $10
    4     5        ASSIGN                                                   !1, <array>
    6     6        COUNT                                            ~13     !0
          7        ASSIGN                                                   !2, ~13
    7     8        COUNT                                            ~15     !1
          9        ASSIGN                                                   !3, ~15
    8    10        ASSIGN                                                   !4, 0
    9    11        ASSIGN                                                   !5, -1
   10    12        INIT_FCALL                                               'min'
         13        SEND_VAR                                                 !2
         14        SEND_VAR                                                 !3
         15        DO_ICALL                                         $19     
         16        ASSIGN                                                   !6, $19
   11    17        ASSIGN                                                   !7, <array>
   13    18        ASSIGN                                                   !8, 0
         19      > JMP                                                      ->58
   15    20    >   ASSIGN                                                   !9, 0
   16    21        ISSET_ISEMPTY_DIM_OBJ                         0  ~24     !0, !8
         22      > JMPZ_EX                                          ~24     ~24, ->25
         23    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~25     !1, !8
         24        BOOL                                             ~24     ~25
         25    > > JMPZ                                                     ~24, ->40
   18    26    >   ECHO                                                     'set'
   19    27        FETCH_DIM_R                                      ~26     !0, !8
         28        FETCH_DIM_R                                      ~27     !1, !8
         29        IS_IDENTICAL                                             ~26, ~27
         30      > JMPZ                                                     ~28, ->38
   21    31    >   PRE_INC                                                  !4
   22    32        ROPE_INIT                                     3  ~31     'hit+'
         33        ROPE_ADD                                      1  ~31     ~31, !8
         34        ROPE_END                                      2  ~30     ~31, '%0A'
         35        ECHO                                                     ~30
   23    36        ASSIGN                                                   !5, -1
         37      > JMP                                                      ->39
   26    38    >   ASSIGN                                                   !9, 1
         39    > > JMP                                                      ->41
   30    40    >   ASSIGN                                                   !9, 1
   32    41    >   IS_EQUAL                                                 !9, 1
         42      > JMPZ                                                     ~36, ->57
   34    43    >   IS_EQUAL                                                 !5, -1
         44      > JMPZ                                                     ~37, ->56
   36    45    >   IS_SMALLER                                               0, !4
         46      > JMPZ                                                     ~38, ->47
   37    47    >   INIT_FCALL                                               'array_push'
         48        SEND_REF                                                 !7
         49        SEND_VAR                                                 !4
         50        DO_ICALL                                                 
   38    51        ASSIGN                                                   !5, 0
   39    52        INIT_FCALL                                               'array_push'
         53        SEND_REF                                                 !7
         54        SEND_VAL                                                 0
         55        DO_ICALL                                                 
   41    56    >   ASSIGN                                                   !4, 0
   13    57    >   PRE_INC                                                  !8
         58    >   IS_SMALLER                                               !8, !6
         59      > JMPNZ                                                    ~44, ->20
   44    60    >   IS_SMALLER                                               0, !4
         61      > JMPZ                                                     ~45, ->66
   45    62    >   INIT_FCALL                                               'array_push'
         63        SEND_REF                                                 !7
         64        SEND_VAR                                                 !4
         65        DO_ICALL                                                 
   46    66    >   IS_NOT_EQUAL                                             !2, !3
         67      > JMPZ                                                     ~47, ->74
   48    68    >   IS_EQUAL                                                 !5, -1
         69      > JMPZ                                                     ~48, ->74
   49    70    >   INIT_FCALL                                               'array_push'
         71        SEND_REF                                                 !7
         72        SEND_VAL                                                 0
         73        DO_ICALL                                                 
   52    74    >   INIT_FCALL                                               'print_r'
         75        SEND_VAR                                                 !7
         76        DO_ICALL                                                 
         77      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.12 ms | 1404 KiB | 21 Q