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/8AmSk
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%E3%81%AF'
          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 = 62) Position 1 = -2
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/8AmSk
function name:  LevenshteinDistance
number of ops:  37
compiled vars:  !0 = $str1, !1 = $str2, !2 = $d, !3 = $len1, !4 = $len2, !5 = $i1, !6 = $i2
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                                         $8      
          7        ASSIGN                                                   !3, $8
    5     8        INIT_FCALL                                               'mb_strlen'
          9        SEND_VAR                                                 !1
         10        SEND_VAL                                                 'UTF-8'
         11        DO_ICALL                                         $10     
         12        ASSIGN                                                   !4, $10
    6    13        CONCAT                                           ~12     !3, !4
         14        ECHO                                                     ~12
    7    15        ASSIGN                                                   !5, 0
         16      > JMP                                                      ->23
    8    17    >   ASSIGN_DIM                                               !2, !5
         18        OP_DATA                                                  <array>
    9    19        FETCH_DIM_W                                      $15     !2, !5
         20        ASSIGN_DIM                                               $15, 0
         21        OP_DATA                                                  !5
    7    22        PRE_INC                                                  !5
         23    >   IS_SMALLER_OR_EQUAL                                      !5, !3
         24      > JMPNZ                                                    ~18, ->17
   11    25    >   ASSIGN                                                   !6, 0
         26      > JMP                                                      ->31
   12    27    >   FETCH_DIM_W                                      $20     !2, 0
         28        ASSIGN_DIM                                               $20, !6
         29        OP_DATA                                                  !6
   11    30        PRE_INC                                                  !6
         31    >   IS_SMALLER_OR_EQUAL                                      !6, !4
         32      > JMPNZ                                                    ~23, ->27
   24    33    >   FETCH_DIM_R                                      ~24     !2, !3
         34        FETCH_DIM_R                                      ~25     ~24, !4
         35      > RETURN                                                   ~25
   25    36*     > RETURN                                                   null

End of function levenshteindistance

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.61 ms | 1403 KiB | 16 Q