3v4l.org

run code in 300+ PHP versions simultaneously
<?php function LevenshteinDistance($str1, $str2) { $d = array (); $len1 = mb_strlen($str1,"UTF-8"); $len2 = mb_strlen($str2,"UTF-8"); echo $len1.$len2; for ($i1 = 0; $i1 <= $len1; $i1++) { $d[$i1] = array (); $d[$i1][0] = $i1; } for ($i2 = 0; $i2 <= $len2; $i2++) { $d[0][$i2] = $i2; } for ($i1 = 1; $i1 <= $len1; $i1++) { for ($i2 = 1; $i2 <= $len2; $i2++) { $cost = ($str1[$i1 - 1] == $str2[$i2 - 1]) ? 0 : 1; $d[$i1][$i2] = min( $d[$i1 - 1][$i2 ] + 1, $d[$i1 ][$i2 - 1] + 1, $d[$i1 - 1][$i2 - 1] + $cost ); } } return $d[$len1][$len2]; } echo LevenshteinDistance("こんにち","こんにちわ"); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jtGI5
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'levenshteindistance'
          1        SEND_VAL                                                 '%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1'
          2        SEND_VAL                                                 '%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%82%8F'
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
   27     5      > RETURN                                                   1

Function levenshteindistance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 17
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 27
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 35
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
2 jumps found. (Code = 44) Position 1 = 71, Position 2 = 37
Branch analysis from position: 71
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 35
Branch analysis from position: 74
Branch analysis from position: 35
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 45
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 71, Position 2 = 37
Branch analysis from position: 71
Branch analysis from position: 37
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 71, Position 2 = 37
Branch analysis from position: 71
Branch analysis from position: 37
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 27
Branch analysis from position: 33
Branch analysis from position: 27
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 17
Branch analysis from position: 25
Branch analysis from position: 17
filename:       /in/jtGI5
function name:  LevenshteinDistance
number of ops:  78
compiled vars:  !0 = $str1, !1 = $str2, !2 = $d, !3 = $len1, !4 = $len2, !5 = $i1, !6 = $i2, !7 = $cost
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        ASSIGN                                                   !2, <array>
    4     3        INIT_FCALL                                               'mb_strlen'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 'UTF-8'
          6        DO_ICALL                                         $9      
          7        ASSIGN                                                   !3, $9
    5     8        INIT_FCALL                                               'mb_strlen'
          9        SEND_VAR                                                 !1
         10        SEND_VAL                                                 'UTF-8'
         11        DO_ICALL                                         $11     
         12        ASSIGN                                                   !4, $11
    6    13        CONCAT                                           ~13     !3, !4
         14        ECHO                                                     ~13
    7    15        ASSIGN                                                   !5, 0
         16      > JMP                                                      ->23
    8    17    >   ASSIGN_DIM                                               !2, !5
         18        OP_DATA                                                  <array>
    9    19        FETCH_DIM_W                                      $16     !2, !5
         20        ASSIGN_DIM                                               $16, 0
         21        OP_DATA                                                  !5
    7    22        PRE_INC                                                  !5
         23    >   IS_SMALLER_OR_EQUAL                                      !5, !3
         24      > JMPNZ                                                    ~19, ->17
   11    25    >   ASSIGN                                                   !6, 0
         26      > JMP                                                      ->31
   12    27    >   FETCH_DIM_W                                      $21     !2, 0
         28        ASSIGN_DIM                                               $21, !6
         29        OP_DATA                                                  !6
   11    30        PRE_INC                                                  !6
         31    >   IS_SMALLER_OR_EQUAL                                      !6, !4
         32      > JMPNZ                                                    ~24, ->27
   14    33    >   ASSIGN                                                   !5, 1
         34      > JMP                                                      ->72
   15    35    >   ASSIGN                                                   !6, 1
         36      > JMP                                                      ->69
   16    37    >   SUB                                              ~27     !5, 1
         38        FETCH_DIM_R                                      ~28     !0, ~27
         39        SUB                                              ~29     !6, 1
         40        FETCH_DIM_R                                      ~30     !1, ~29
         41        IS_EQUAL                                                 ~28, ~30
         42      > JMPZ                                                     ~31, ->45
         43    >   QM_ASSIGN                                        ~32     0
         44      > JMP                                                      ->46
         45    >   QM_ASSIGN                                        ~32     1
         46    >   ASSIGN                                                   !7, ~32
   17    47        INIT_FCALL                                               'min'
   18    48        SUB                                              ~36     !5, 1
         49        FETCH_DIM_R                                      ~37     !2, ~36
         50        FETCH_DIM_R                                      ~38     ~37, !6
         51        ADD                                              ~39     ~38, 1
         52        SEND_VAL                                                 ~39
   19    53        SUB                                              ~41     !6, 1
         54        FETCH_DIM_R                                      ~40     !2, !5
         55        FETCH_DIM_R                                      ~42     ~40, ~41
         56        ADD                                              ~43     ~42, 1
         57        SEND_VAL                                                 ~43
   20    58        SUB                                              ~44     !5, 1
         59        SUB                                              ~46     !6, 1
         60        FETCH_DIM_R                                      ~45     !2, ~44
         61        FETCH_DIM_R                                      ~47     ~45, ~46
         62        ADD                                              ~48     ~47, !7
         63        SEND_VAL                                                 ~48
         64        DO_ICALL                                         $49     
   17    65        FETCH_DIM_W                                      $34     !2, !5
         66        ASSIGN_DIM                                               $34, !6
   20    67        OP_DATA                                                  $49
   15    68        PRE_INC                                                  !6
         69    >   IS_SMALLER_OR_EQUAL                                      !6, !4
         70      > JMPNZ                                                    ~51, ->37
   14    71    >   PRE_INC                                                  !5
         72    >   IS_SMALLER_OR_EQUAL                                      !5, !3
         73      > JMPNZ                                                    ~53, ->35
   24    74    >   FETCH_DIM_R                                      ~54     !2, !3
         75        FETCH_DIM_R                                      ~55     ~54, !4
         76      > RETURN                                                   ~55
   25    77*     > RETURN                                                   null

End of function levenshteindistance

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.69 ms | 1407 KiB | 18 Q