3v4l.org

run code in 300+ PHP versions simultaneously
<?php function toAscii($s) { static $transliterator = NULL; if ($transliterator === NULL && class_exists('Transliterator', FALSE)) { $transliterator = \Transliterator::create('Any-Latin; Latin-ASCII'); } $s = preg_replace('#[^\x09\x0A\x0D\x20-\x7E\xA0-\x{2FF}\x{370}-\x{10FFFF}]#u', '', $s); $s = strtr($s, '`\'"^~?', "\x01\x02\x03\x04\x05\x06"); $s = str_replace( ["\xE2\x80\x9E", "\xE2\x80\x9C", "\xE2\x80\x9D", "\xE2\x80\x9A", "\xE2\x80\x98", "\xE2\x80\x99", "\xC2\xB0"], ["\x03", "\x03", "\x03", "\x02", "\x02", "\x02", "\x04"], $s ); if ($transliterator !== NULL) { $s = $transliterator->transliterate($s); } if (ICONV_IMPL === 'glibc') { $s = str_replace( ["\xC2\xBB", "\xC2\xAB", "\xE2\x80\xA6", "\xE2\x84\xA2", "\xC2\xA9", "\xC2\xAE"], ['>>', '<<', '...', 'TM', '(c)', '(R)'], $s ); $s = iconv('UTF-8', 'WINDOWS-1250//TRANSLIT//IGNORE', $s); $s = strtr($s, "\xa5\xa3\xbc\x8c\xa7\x8a\xaa\x8d\x8f\x8e\xaf\xb9\xb3\xbe\x9c\x9a\xba\x9d\x9f\x9e" . "\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3" . "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8" . "\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf8\xf9\xfa\xfb\xfc\xfd\xfe" . "\x96\xa0\x8b\x97\x9b\xa6\xad\xb7", 'ALLSSSSTZZZallssstzzzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTsraaaalccceeeeiiddnnooooruuuuyt- <->|-.'); $s = preg_replace('#[^\x00-\x7F]++#', '', $s); } else { $s = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $s); } $s = str_replace(['`', "'", '"', '^', '~', '?'], '', $s); return strtr($s, "\x01\x02\x03\x04\x05\x06", '`\'"^~?'); } echo toAscii('ášěíáčšíěá');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QJ7Jk
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'toascii'
          1        SEND_VAL                                                 '%C3%A1%C5%A1%C4%9B%C3%AD%C3%A1%C4%8D%C5%A1%C3%AD%C4%9B%C3%A1'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function toascii:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 38
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 66
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
Branch analysis from position: 14
Branch analysis from position: 9
filename:       /in/QJ7Jk
function name:  toAscii
number of ops:  85
compiled vars:  !0 = $s, !1 = $transliterator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        BIND_STATIC                                              !1
    4     2        TYPE_CHECK                                    2  ~2      !1
          3      > JMPZ_EX                                          ~2      ~2, ->9
          4    >   INIT_FCALL                                               'class_exists'
          5        SEND_VAL                                                 'Transliterator'
          6        SEND_VAL                                                 <false>
          7        DO_ICALL                                         $3      
          8        BOOL                                             ~2      $3
          9    > > JMPZ                                                     ~2, ->14
    5    10    >   INIT_STATIC_METHOD_CALL                                  'Transliterator', 'create'
         11        SEND_VAL_EX                                              'Any-Latin%3B+Latin-ASCII'
         12        DO_FCALL                                      0  $4      
         13        ASSIGN                                                   !1, $4
    8    14    >   INIT_FCALL                                               'preg_replace'
         15        SEND_VAL                                                 '%23%5B%5E%5Cx09%5Cx0A%5Cx0D%5Cx20-%5Cx7E%5CxA0-%5Cx%7B2FF%7D%5Cx%7B370%7D-%5Cx%7B10FFFF%7D%5D%23u'
         16        SEND_VAL                                                 ''
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $6      
         19        ASSIGN                                                   !0, $6
    9    20        INIT_FCALL                                               'strtr'
         21        SEND_VAR                                                 !0
         22        SEND_VAL                                                 '%60%27%22%5E%7E%3F'
         23        SEND_VAL                                                 '%01%02%03%04%05%06'
         24        DO_ICALL                                         $8      
         25        ASSIGN                                                   !0, $8
   10    26        INIT_FCALL                                               'str_replace'
   11    27        SEND_VAL                                                 <array>
   12    28        SEND_VAL                                                 <array>
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                         $10     
   10    31        ASSIGN                                                   !0, $10
   14    32        TYPE_CHECK                                  1020          !1
         33      > JMPZ                                                     ~12, ->38
   15    34    >   INIT_METHOD_CALL                                         !1, 'transliterate'
         35        SEND_VAR_EX                                              !0
         36        DO_FCALL                                      0  $13     
         37        ASSIGN                                                   !0, $13
   17    38    >   FETCH_CONSTANT                                   ~15     'ICONV_IMPL'
         39        IS_IDENTICAL                                             ~15, 'glibc'
         40      > JMPZ                                                     ~16, ->66
   18    41    >   INIT_FCALL                                               'str_replace'
   19    42        SEND_VAL                                                 <array>
   20    43        SEND_VAL                                                 <array>
         44        SEND_VAR                                                 !0
         45        DO_ICALL                                         $17     
   18    46        ASSIGN                                                   !0, $17
   22    47        INIT_FCALL_BY_NAME                                       'iconv'
         48        SEND_VAL_EX                                              'UTF-8'
         49        SEND_VAL_EX                                              'WINDOWS-1250%2F%2FTRANSLIT%2F%2FIGNORE'
         50        SEND_VAR_EX                                              !0
         51        DO_FCALL                                      0  $19     
         52        ASSIGN                                                   !0, $19
   23    53        INIT_FCALL                                               'strtr'
         54        SEND_VAR                                                 !0
   27    55        SEND_VAL                                                 '%A5%A3%BC%8C%A7%8A%AA%8D%8F%8E%AF%B9%B3%BE%9C%9A%BA%9D%9F%9E%BF%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F8%F9%FA%FB%FC%FD%FE%96%A0%8B%97%9B%A6%AD%B7'
   28    56        SEND_VAL                                                 'ALLSSSSTZZZallssstzzzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTsraaaalccceeeeiiddnnooooruuuuyt-+%3C-%3E%7C-.'
         57        DO_ICALL                                         $21     
   23    58        ASSIGN                                                   !0, $21
   29    59        INIT_FCALL                                               'preg_replace'
         60        SEND_VAL                                                 '%23%5B%5E%5Cx00-%5Cx7F%5D%2B%2B%23'
         61        SEND_VAL                                                 ''
         62        SEND_VAR                                                 !0
         63        DO_ICALL                                         $23     
         64        ASSIGN                                                   !0, $23
         65      > JMP                                                      ->72
   31    66    >   INIT_FCALL_BY_NAME                                       'iconv'
         67        SEND_VAL_EX                                              'UTF-8'
         68        SEND_VAL_EX                                              'ASCII%2F%2FTRANSLIT%2F%2FIGNORE'
         69        SEND_VAR_EX                                              !0
         70        DO_FCALL                                      0  $25     
         71        ASSIGN                                                   !0, $25
   33    72    >   INIT_FCALL                                               'str_replace'
         73        SEND_VAL                                                 <array>
         74        SEND_VAL                                                 ''
         75        SEND_VAR                                                 !0
         76        DO_ICALL                                         $27     
         77        ASSIGN                                                   !0, $27
   34    78        INIT_FCALL                                               'strtr'
         79        SEND_VAR                                                 !0
         80        SEND_VAL                                                 '%01%02%03%04%05%06'
         81        SEND_VAL                                                 '%60%27%22%5E%7E%3F'
         82        DO_ICALL                                         $29     
         83      > RETURN                                                   $29
   35    84*     > RETURN                                                   null

End of function toascii

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.71 ms | 1407 KiB | 22 Q