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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
205.29 ms | 1404 KiB | 21 Q