3v4l.org

run code in 300+ PHP versions simultaneously
<?php function slugify($text) { // replace non letter or digits by - $text = preg_replace('~[^\\pL\d]+~u', '-', $text); // trim $text = trim($text, '-'); // transliterate $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); echo $text . "\n"; // lowercase $text = strtolower($text); // remove unwanted characters $text = preg_replace('~[^-\w]+~', '', $text); if (empty($text)) { return 'n-a'; } return $text; } echo slugify('Тестовый пример');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qTfgb
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'slugify'
          1        SEND_VAL                                                 '%D0%A2%D0%B5%D1%81%D1%82%D0%BE%D0%B2%D1%8B%D0%B9+%D0%BF%D1%80%D0%B8%D0%BC%D0%B5%D1%80'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function slugify:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qTfgb
function name:  slugify
number of ops:  35
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%7E%5B%5E%5CpL%5Cd%5D%2B%7Eu'
          3        SEND_VAL                                                 '-'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6        ASSIGN                                                   !0, $1
   10     7        INIT_FCALL                                               'trim'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 '-'
         10        DO_ICALL                                         $3      
         11        ASSIGN                                                   !0, $3
   13    12        INIT_FCALL_BY_NAME                                       'iconv'
         13        SEND_VAL_EX                                              'utf-8'
         14        SEND_VAL_EX                                              'us-ascii%2F%2FTRANSLIT'
         15        SEND_VAR_EX                                              !0
         16        DO_FCALL                                      0  $5      
         17        ASSIGN                                                   !0, $5
   14    18        CONCAT                                           ~7      !0, '%0A'
         19        ECHO                                                     ~7
   17    20        INIT_FCALL                                               'strtolower'
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $8      
         23        ASSIGN                                                   !0, $8
   20    24        INIT_FCALL                                               'preg_replace'
         25        SEND_VAL                                                 '%7E%5B%5E-%5Cw%5D%2B%7E'
         26        SEND_VAL                                                 ''
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $10     
         29        ASSIGN                                                   !0, $10
   22    30        ISSET_ISEMPTY_CV                                         !0
         31      > JMPZ                                                     ~12, ->33
   24    32    > > RETURN                                                   'n-a'
   27    33    > > RETURN                                                   !0
   28    34*     > RETURN                                                   null

End of function slugify

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.51 ms | 1403 KiB | 20 Q