3v4l.org

run code in 300+ PHP versions simultaneously
<?php function edit_distance_ond($str1 ,$str2){ $array = array(); $x; $y; $offset = count($str1); $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 = "ttst2"; $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/T8btR
function name:  (null)
number of ops:  9
compiled vars:  !0 = $a, !1 = $b, !2 = $edo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ASSIGN                                                   !0, 'test'
   27     1        ASSIGN                                                   !1, 'ttst2'
   28     2        INIT_FCALL                                               'edit_distance_ond'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !2, $5
   29     7        ECHO                                                     !2
   30     8      > RETURN                                                   1

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

End of function edit_distance_ond

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.63 ms | 1407 KiB | 14 Q