3v4l.org

run code in 300+ PHP versions simultaneously
<?php $acceptSpaces = true; $acceptUppercase = true; $text = 'El méu tëst'; // Replace non letter or digits by - $pattern = $acceptSpaces ? '~[^\\pL\d]+~u' : '~[^ \\pL\d]+~u'; $text = preg_replace($pattern, '-', $text); var_dump('preg replace', $text); // Trim $text = trim($text, '-'); var_dump('trim', $text); // Transliterate $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); var_dump('transliterate', $text); if(!$acceptUppercase) { // Lowercase $text = strtolower($text); } var_dump('lower', $text); // Remove unwanted characters $pattern = $acceptSpaces ? '~[^ -\w]+~' : '~[^-\w]+~'; $text = preg_replace($pattern, '', $text); var_dump('replace2', $text); var_dump( $text );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 43
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 50
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 43
Branch analysis from position: 39
Branch analysis from position: 43
filename:       /in/gYp9H
function name:  (null)
number of ops:  66
compiled vars:  !0 = $acceptSpaces, !1 = $acceptUppercase, !2 = $text, !3 = $pattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <true>
    4     1        ASSIGN                                                   !1, <true>
    6     2        ASSIGN                                                   !2, 'El+m%C3%A9u+t%C3%ABst'
    9     3      > JMPZ                                                     !0, ->6
   10     4    >   QM_ASSIGN                                        ~7      '%7E%5B%5E%5CpL%5Cd%5D%2B%7Eu'
          5      > JMP                                                      ->7
   11     6    >   QM_ASSIGN                                        ~7      '%7E%5B%5E+%5CpL%5Cd%5D%2B%7Eu'
    9     7    >   ASSIGN                                                   !3, ~7
   12     8        INIT_FCALL                                               'preg_replace'
          9        SEND_VAR                                                 !3
         10        SEND_VAL                                                 '-'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $9      
         13        ASSIGN                                                   !2, $9
   14    14        INIT_FCALL                                               'var_dump'
         15        SEND_VAL                                                 'preg+replace'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                                 
   17    18        INIT_FCALL                                               'trim'
         19        SEND_VAR                                                 !2
         20        SEND_VAL                                                 '-'
         21        DO_ICALL                                         $12     
         22        ASSIGN                                                   !2, $12
   19    23        INIT_FCALL                                               'var_dump'
         24        SEND_VAL                                                 'trim'
         25        SEND_VAR                                                 !2
         26        DO_ICALL                                                 
   22    27        INIT_FCALL_BY_NAME                                       'iconv'
         28        SEND_VAL_EX                                              'utf-8'
         29        SEND_VAL_EX                                              'us-ascii%2F%2FTRANSLIT'
         30        SEND_VAR_EX                                              !2
         31        DO_FCALL                                      0  $15     
         32        ASSIGN                                                   !2, $15
   24    33        INIT_FCALL                                               'var_dump'
         34        SEND_VAL                                                 'transliterate'
         35        SEND_VAR                                                 !2
         36        DO_ICALL                                                 
   26    37        BOOL_NOT                                         ~18     !1
         38      > JMPZ                                                     ~18, ->43
   28    39    >   INIT_FCALL                                               'strtolower'
         40        SEND_VAR                                                 !2
         41        DO_ICALL                                         $19     
         42        ASSIGN                                                   !2, $19
   31    43    >   INIT_FCALL                                               'var_dump'
         44        SEND_VAL                                                 'lower'
         45        SEND_VAR                                                 !2
         46        DO_ICALL                                                 
   34    47      > JMPZ                                                     !0, ->50
   35    48    >   QM_ASSIGN                                        ~22     '%7E%5B%5E+-%5Cw%5D%2B%7E'
         49      > JMP                                                      ->51
   36    50    >   QM_ASSIGN                                        ~22     '%7E%5B%5E-%5Cw%5D%2B%7E'
   34    51    >   ASSIGN                                                   !3, ~22
   37    52        INIT_FCALL                                               'preg_replace'
         53        SEND_VAR                                                 !3
         54        SEND_VAL                                                 ''
         55        SEND_VAR                                                 !2
         56        DO_ICALL                                         $24     
         57        ASSIGN                                                   !2, $24
   39    58        INIT_FCALL                                               'var_dump'
         59        SEND_VAL                                                 'replace2'
         60        SEND_VAR                                                 !2
         61        DO_ICALL                                                 
   41    62        INIT_FCALL                                               'var_dump'
         63        SEND_VAR                                                 !2
         64        DO_ICALL                                                 
         65      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.88 ms | 948 KiB | 22 Q