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); echo $offset; $array[$offset + 1] = 0; for($D = 0; $D <= count($str1) + count($str2); $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 < count($str1) && $y < count($str2) && $str1[$x] == $str2[$y]){ $x++; $y++; } $array[$k+$offset] = $x; if($x >= count($str1) && $y >= count($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/l6YBl
function name:  (null)
number of ops:  9
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
   30     7        ECHO                                                     !2
   31     8      > RETURN                                                   1

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

End of function edit_distance_ond

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.89 ms | 1407 KiB | 14 Q