3v4l.org

run code in 300+ PHP versions simultaneously
<?php function edit_distance_ond($str1 ,$str2){ $array = array(); $x = 0; $y = 0; $offset = strlen($str1); $array[$offset + 1] = 0; for($D = 0; $D <= strlen($str1) + strlen($str2); $D++){ echo $D." "; for($k = -$D; $k <= $D; $k += 2){ if($k == -$D || $k != $D && $array[$k-1+$offset] < $array[$k+1+$offset]) $x = $array[$k+1+$offset]; else $x = $array[$k-1+$offset] + 1; $y = $x - $k; while($x < strlen($str1) && $y < strlen($str2) && $str1[$x] == $str2[$y]){ $x++; $y++; } $array[$k+$offset] = $x; if($x >= strlen($str1) && $y >= strlen($str2)) return $D; } } return -1; } $a = "test"; $b = "test2"; $edo = edit_distance_ond($a,$b); //echo $edo; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/p6its
function name:  (null)
number of ops:  8
compiled vars:  !0 = $a, !1 = $b, !2 = $edo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   ASSIGN                                                   !0, 'test'
   28     1        ASSIGN                                                   !1, 'test2'
   29     2        INIT_FCALL                                               'edit_distance_ond'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !2, $5
   31     7      > RETURN                                                   1

Function edit_distance_ond:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
2 jumps found. (Code = 44) Position 1 = 79, Position 2 = 12
Branch analysis from position: 79
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
2 jumps found. (Code = 44) Position 1 = 73, Position 2 = 17
Branch analysis from position: 73
2 jumps found. (Code = 44) Position 1 = 79, Position 2 = 12
Branch analysis from position: 79
Branch analysis from position: 12
Branch analysis from position: 17
2 jumps found. (Code = 47) Position 1 = 20, Position 2 = 31
Branch analysis from position: 20
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 30
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 37
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
2 jumps found. (Code = 46) Position 1 = 50, Position 2 = 53
Branch analysis from position: 50
2 jumps found. (Code = 46) Position 1 = 54, Position 2 = 58
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 45
Branch analysis from position: 59
2 jumps found. (Code = 46) Position 1 = 65, Position 2 = 68
Branch analysis from position: 65
2 jumps found. (Code = 43) Position 1 = 69, Position 2 = 70
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 73, Position 2 = 17
Branch analysis from position: 73
Branch analysis from position: 17
Branch analysis from position: 68
Branch analysis from position: 45
2 jumps found. (Code = 46) Position 1 = 50, Position 2 = 53
Branch analysis from position: 50
Branch analysis from position: 53
Branch analysis from position: 58
Branch analysis from position: 53
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 30
Branch analysis from position: 31
filename:       /in/p6its
function name:  edit_distance_ond
number of ops:  81
compiled vars:  !0 = $str1, !1 = $str2, !2 = $array, !3 = $x, !4 = $y, !5 = $offset, !6 = $D, !7 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        ASSIGN                                                   !2, <array>
    4     3        ASSIGN                                                   !3, 0
    5     4        ASSIGN                                                   !4, 0
    6     5        STRLEN                                           ~11     !0
          6        ASSIGN                                                   !5, ~11
    7     7        ADD                                              ~13     !5, 1
          8        ASSIGN_DIM                                               !2, ~13
          9        OP_DATA                                                  0
    8    10        ASSIGN                                                   !6, 0
         11      > JMP                                                      ->74
    9    12    >   CONCAT                                           ~16     !6, '+'
         13        ECHO                                                     ~16
   10    14        MUL                                              ~17     !6, -1
         15        ASSIGN                                                   !7, ~17
         16      > JMP                                                      ->71
   11    17    >   MUL                                              ~19     !6, -1
         18        IS_EQUAL                                         ~20     !7, ~19
         19      > JMPNZ_EX                                         ~20     ~20, ->31
         20    >   IS_NOT_EQUAL                                     ~21     !7, !6
         21      > JMPZ_EX                                          ~21     ~21, ->30
         22    >   SUB                                              ~22     !7, 1
         23        ADD                                              ~23     ~22, !5
         24        FETCH_DIM_R                                      ~24     !2, ~23
         25        ADD                                              ~25     !7, 1
         26        ADD                                              ~26     ~25, !5
         27        FETCH_DIM_R                                      ~27     !2, ~26
         28        IS_SMALLER                                       ~28     ~24, ~27
         29        BOOL                                             ~21     ~28
         30    >   BOOL                                             ~20     ~21
         31    > > JMPZ                                                     ~20, ->37
   12    32    >   ADD                                              ~29     !7, 1
         33        ADD                                              ~30     ~29, !5
         34        FETCH_DIM_R                                      ~31     !2, ~30
         35        ASSIGN                                                   !3, ~31
         36      > JMP                                                      ->42
   14    37    >   SUB                                              ~33     !7, 1
         38        ADD                                              ~34     ~33, !5
         39        FETCH_DIM_R                                      ~35     !2, ~34
         40        ADD                                              ~36     ~35, 1
         41        ASSIGN                                                   !3, ~36
   15    42    >   SUB                                              ~38     !3, !7
         43        ASSIGN                                                   !4, ~38
   16    44      > JMP                                                      ->47
   17    45    >   PRE_INC                                                  !3
   18    46        PRE_INC                                                  !4
   16    47    >   STRLEN                                           ~42     !0
         48        IS_SMALLER                                       ~43     !3, ~42
         49      > JMPZ_EX                                          ~43     ~43, ->53
         50    >   STRLEN                                           ~44     !1
         51        IS_SMALLER                                       ~45     !4, ~44
         52        BOOL                                             ~43     ~45
         53    > > JMPZ_EX                                          ~43     ~43, ->58
         54    >   FETCH_DIM_R                                      ~46     !0, !3
         55        FETCH_DIM_R                                      ~47     !1, !4
         56        IS_EQUAL                                         ~48     ~46, ~47
         57        BOOL                                             ~43     ~48
         58    > > JMPNZ                                                    ~43, ->45
   20    59    >   ADD                                              ~49     !7, !5
         60        ASSIGN_DIM                                               !2, ~49
         61        OP_DATA                                                  !3
   21    62        STRLEN                                           ~51     !0
         63        IS_SMALLER_OR_EQUAL                              ~52     ~51, !3
         64      > JMPZ_EX                                          ~52     ~52, ->68
         65    >   STRLEN                                           ~53     !1
         66        IS_SMALLER_OR_EQUAL                              ~54     ~53, !4
         67        BOOL                                             ~52     ~54
         68    > > JMPZ                                                     ~52, ->70
   22    69    > > RETURN                                                   !6
   10    70    >   ASSIGN_OP                                     1          !7, 2
         71    >   IS_SMALLER_OR_EQUAL                                      !7, !6
         72      > JMPNZ                                                    ~56, ->17
    8    73    >   PRE_INC                                                  !6
         74    >   STRLEN                                           ~58     !0
         75        STRLEN                                           ~59     !1
         76        ADD                                              ~60     ~58, ~59
         77        IS_SMALLER_OR_EQUAL                                      !6, ~60
         78      > JMPNZ                                                    ~61, ->12
   25    79    > > RETURN                                                   -1
   26    80*     > RETURN                                                   null

End of function edit_distance_ond

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.65 ms | 1398 KiB | 14 Q