3v4l.org

run code in 500+ PHP versions simultaneously
<?php function make_ascii($str) { //return $str; $special = array('ľ','š','č','ť','ž','ý','á','í','é','ú','ä','ô','ň','ě'); $ascii = array('l','s','c','t','z','y','a','i','e','u','a','o','n','e'); $str = array_map(function ($i) use ($str) { return mb_substr($str, $i, 1); }, range(0, mb_strlen($str) -1)); //var_dump($str); foreach ($str as $k => $c) { if(ctype_upper($c)) { $u = true; $c = strtolower($c); } else { $u = false; } // print_r($c); if(in_array($c, $special)) { $c = $ascii[array_search($c, $special)]; } if($u) { $c = strtoupper($c); } $str[$k] = $c; } return join($str); } var_dump(make_ascii('áé'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HYlqj
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   30     0  E >   INIT_FCALL                                                   'var_dump'
          1        INIT_FCALL                                                   'make_ascii'
          2        SEND_VAL                                                     '%C3%A1%C3%A9'
          3        DO_FCALL                                          0  $0      
          4        SEND_VAR                                                     $0
          5        DO_ICALL                                                     
          6      > RETURN                                                       1

Function make_ascii:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 48
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 48
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 31
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 40
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 45
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 45
Branch analysis from position: 40
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 40
Branch analysis from position: 34
Branch analysis from position: 40
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
filename:       /in/HYlqj
function name:  make_ascii
number of ops:  54
compiled vars:  !0 = $str, !1 = $special, !2 = $ascii, !3 = $c, !4 = $k, !5 = $u
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        ASSIGN                                                       !1, <array>
    6     2        ASSIGN                                                       !2, <array>
    7     3        INIT_FCALL                                                   'array_map'
          4        DECLARE_LAMBDA_FUNCTION                              ~8      [0]
          5        BIND_LEXICAL                                                 ~8, !0
    9     6        SEND_VAL                                                     ~8
          7        INIT_FCALL                                                   'range'
          8        SEND_VAL                                                     0
          9        INIT_FCALL                                                   'mb_strlen'
         10        SEND_VAR                                                     !0
         11        DO_ICALL                                             $9      
         12        SUB                                                  ~10     $9, 1
         13        SEND_VAL                                                     ~10
         14        DO_ICALL                                             $11     
         15        SEND_VAR                                                     $11
    7    16        DO_ICALL                                             $12     
         17        ASSIGN                                                       !0, $12
   11    18      > FE_RESET_R                                           $14     !0, ->48
         19    > > FE_FETCH_R                                           ~15     $14, !3, ->48
         20    >   ASSIGN                                                       !4, ~15
   12    21        INIT_FCALL                                                   'ctype_upper'
         22        SEND_VAR                                                     !3
         23        DO_ICALL                                             $17     
         24      > JMPZ                                                         $17, ->31
   13    25    >   ASSIGN                                                       !5, <true>
   14    26        INIT_FCALL                                                   'strtolower'
         27        SEND_VAR                                                     !3
         28        DO_ICALL                                             $19     
         29        ASSIGN                                                       !3, $19
   12    30      > JMP                                                          ->32
   16    31    >   ASSIGN                                                       !5, <false>
   19    32    >   FRAMELESS_ICALL_2                in_array            ~22     !3, !1
         33      > JMPZ                                                         ~22, ->40
   20    34    >   INIT_FCALL                                                   'array_search'
         35        SEND_VAR                                                     !3
         36        SEND_VAR                                                     !1
         37        DO_ICALL                                             $23     
         38        FETCH_DIM_R                                          ~24     !2, $23
         39        ASSIGN                                                       !3, ~24
   22    40    > > JMPZ                                                         !5, ->45
   23    41    >   INIT_FCALL                                                   'strtoupper'
         42        SEND_VAR                                                     !3
         43        DO_ICALL                                             $26     
         44        ASSIGN                                                       !3, $26
   25    45    >   ASSIGN_DIM                                                   !0, !4
         46        OP_DATA                                                      !3
   11    47      > JMP                                                          ->19
         48    >   FE_FREE                                                      $14
   27    49        INIT_FCALL                                                   'join'
         50        SEND_VAR                                                     !0
         51        DO_ICALL                                             $29     
         52      > RETURN                                                       $29
   28    53*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HYlqj
function name:  {closure:make_ascii():7}
number of ops:  9
compiled vars:  !0 = $i, !1 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
    8     2        INIT_FCALL                                                   'mb_substr'
          3        SEND_VAR                                                     !1
          4        SEND_VAR                                                     !0
          5        SEND_VAL                                                     1
          6        DO_ICALL                                             $2      
          7      > RETURN                                                       $2
    9     8*     > RETURN                                                       null

End of Dynamic Function 0

End of function make_ascii

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.85 ms | 2172 KiB | 24 Q