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); // 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/rV9pM
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'slugify'
          1        SEND_VAL                                                 '%C5%A1%C4%91%C4%8D%C4%87%C5%BE+%C5%A0%C4%90%C4%8C%C4%86%C5%BD'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   29     4      > RETURN                                                   1

Function slugify:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 31
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rV9pM
function name:  slugify
number of ops:  33
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    5     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
    8     7        INIT_FCALL                                               'trim'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 '-'
         10        DO_ICALL                                         $3      
         11        ASSIGN                                                   !0, $3
   11    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        INIT_FCALL                                               'strtolower'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $7      
         21        ASSIGN                                                   !0, $7
   17    22        INIT_FCALL                                               'preg_replace'
         23        SEND_VAL                                                 '%7E%5B%5E-%5Cw%5D%2B%7E'
         24        SEND_VAL                                                 ''
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                         $9      
         27        ASSIGN                                                   !0, $9
   19    28        ISSET_ISEMPTY_CV                                         !0
         29      > JMPZ                                                     ~11, ->31
   21    30    > > RETURN                                                   'n-a'
   24    31    > > RETURN                                                   !0
   25    32*     > RETURN                                                   null

End of function slugify

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.44 ms | 1403 KiB | 23 Q