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++) { if($array1[$i] === $array2[$i]) { $hit++; $miss = -1; } else { 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 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 20
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 50
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 58
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 58
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
Branch analysis from position: 58
Branch analysis from position: 50
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 20
Branch analysis from position: 44
Branch analysis from position: 20
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 40
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 20
Branch analysis from position: 44
Branch analysis from position: 20
Branch analysis from position: 31
Branch analysis from position: 40
filename:       /in/nC0OV
function name:  (null)
number of ops:  62
compiled vars:  !0 = $array1, !1 = $array2, !2 = $size1, !3 = $size2, !4 = $hit, !5 = $miss, !6 = $min_size, !7 = $array3, !8 = $i
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                                         $9      
          4        ASSIGN                                                   !0, $9
    4     5        ASSIGN                                                   !1, <array>
    6     6        COUNT                                            ~12     !0
          7        ASSIGN                                                   !2, ~12
    7     8        COUNT                                            ~14     !1
          9        ASSIGN                                                   !3, ~14
    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                                         $18     
         16        ASSIGN                                                   !6, $18
   11    17        ASSIGN                                                   !7, <array>
   12    18        ASSIGN                                                   !8, 0
         19      > JMP                                                      ->42
   14    20    >   FETCH_DIM_R                                      ~22     !0, !8
         21        FETCH_DIM_R                                      ~23     !1, !8
         22        IS_IDENTICAL                                             ~22, ~23
         23      > JMPZ                                                     ~24, ->27
   16    24    >   PRE_INC                                                  !4
   17    25        ASSIGN                                                   !5, -1
         26      > JMP                                                      ->41
   21    27    >   IS_EQUAL                                                 !5, -1
         28      > JMPZ                                                     ~27, ->40
   23    29    >   IS_SMALLER                                               0, !4
         30      > JMPZ                                                     ~28, ->31
   24    31    >   INIT_FCALL                                               'array_push'
         32        SEND_REF                                                 !7
         33        SEND_VAR                                                 !4
         34        DO_ICALL                                                 
   25    35        ASSIGN                                                   !5, 0
   26    36        INIT_FCALL                                               'array_push'
         37        SEND_REF                                                 !7
         38        SEND_VAL                                                 0
         39        DO_ICALL                                                 
   28    40    >   ASSIGN                                                   !4, 0
   12    41    >   PRE_INC                                                  !8
         42    >   IS_SMALLER                                               !8, !6
         43      > JMPNZ                                                    ~34, ->20
   31    44    >   IS_SMALLER                                               0, !4
         45      > JMPZ                                                     ~35, ->50
   32    46    >   INIT_FCALL                                               'array_push'
         47        SEND_REF                                                 !7
         48        SEND_VAR                                                 !4
         49        DO_ICALL                                                 
   33    50    >   IS_NOT_EQUAL                                             !2, !3
         51      > JMPZ                                                     ~37, ->58
   35    52    >   IS_EQUAL                                                 !5, -1
         53      > JMPZ                                                     ~38, ->58
   36    54    >   INIT_FCALL                                               'array_push'
         55        SEND_REF                                                 !7
         56        SEND_VAL                                                 0
         57        DO_ICALL                                                 
   39    58    >   INIT_FCALL                                               'print_r'
         59        SEND_VAR                                                 !7
         60        DO_ICALL                                                 
         61      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.38 ms | 1400 KiB | 21 Q