3v4l.org

run code in 300+ PHP versions simultaneously
<?php $map = array(); var_dump(levenshtein(utf8_to_extended_ascii('приве', $map), utf8_to_extended_ascii('привет', $map))); function utf8_to_extended_ascii($str, &$map) { // find all multibyte characters (cf. utf-8 encoding specs) $matches = array(); if (!preg_match_all('/[\xC0-\xF7][\x80-\xBF]+/', $str, $matches)) return $str; // plain ascii string // update the encoding map with the characters not already met foreach ($matches[0] as $mbc) if (!isset($map[$mbc])) $map[$mbc] = chr(128 + count($map)); // finally remap non-ascii characters return strtr($str, $map); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tju5R
function name:  (null)
number of ops:  17
compiled vars:  !0 = $map
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'levenshtein'
          3        INIT_FCALL_BY_NAME                                       'utf8_to_extended_ascii'
          4        SEND_VAL_EX                                              '%D0%BF%D1%80%D0%B8%D0%B2%D0%B5'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR                                                 $2
          8        INIT_FCALL_BY_NAME                                       'utf8_to_extended_ascii'
          9        SEND_VAL_EX                                              '%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0  $3      
         12        SEND_VAR                                                 $3
         13        DO_ICALL                                         $4      
         14        SEND_VAR                                                 $4
         15        DO_ICALL                                                 
   21    16      > RETURN                                                   1

Function utf8_to_extended_ascii:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 25
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 25
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 24
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 24
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/tju5R
function name:  utf8_to_extended_ascii
number of ops:  32
compiled vars:  !0 = $str, !1 = $map, !2 = $matches, !3 = $mbc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        ASSIGN                                                   !2, <array>
   11     3        INIT_FCALL                                               'preg_match_all'
          4        SEND_VAL                                                 '%2F%5B%5CxC0-%5CxF7%5D%5B%5Cx80-%5CxBF%5D%2B%2F'
          5        SEND_VAR                                                 !0
          6        SEND_REF                                                 !2
          7        DO_ICALL                                         $5      
          8        BOOL_NOT                                         ~6      $5
          9      > JMPZ                                                     ~6, ->11
   12    10    > > RETURN                                                   !0
   15    11    >   FETCH_DIM_R                                      ~7      !2, 0
         12      > FE_RESET_R                                       $8      ~7, ->25
         13    > > FE_FETCH_R                                               $8, !3, ->25
   16    14    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~9      !1, !3
         15        BOOL_NOT                                         ~10     ~9
         16      > JMPZ                                                     ~10, ->24
   17    17    >   INIT_FCALL                                               'chr'
         18        COUNT                                            ~12     !1
         19        ADD                                              ~13     128, ~12
         20        SEND_VAL                                                 ~13
         21        DO_ICALL                                         $14     
         22        ASSIGN_DIM                                               !1, !3
         23        OP_DATA                                                  $14
   15    24    > > JMP                                                      ->13
         25    >   FE_FREE                                                  $8
   20    26        INIT_FCALL                                               'strtr'
         27        SEND_VAR                                                 !0
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                         $15     
         30      > RETURN                                                   $15
   21    31*     > RETURN                                                   null

End of function utf8_to_extended_ascii

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.73 ms | 1400 KiB | 23 Q