3v4l.org

run code in 300+ PHP versions simultaneously
<?php function slugify($str, $maxLength = null, $separator = '-') { if(function_exists('transliterator_transliterate')) { $str = transliterator_transliterate("Any-Latin; Latin-ASCII; Lower()", $str); } $str = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $str); $str = preg_replace('/[^a-zA-Z0-9\/_|\'\. -]/', '', $str); if($maxLength !== null) { substr($str, 0, $maxLength); } $str = preg_replace('/[\/_| -]+/', $separator, $str); return trim(strtolower($str), $separator); } var_dump(slugify('Iñtërnâtiônàlizætiøn - is the greatest! ')); var_dump(slugify(' ^*_:香港 åä?ö ')); var_dump(slugify('των υιών')); var_dump(slugify('Ελληνική Δημοκρατία'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lcChO
function name:  (null)
number of ops:  25
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'slugify'
          2        SEND_VAL                                                 'I%C3%B1t%C3%ABrn%C3%A2ti%C3%B4n%C3%A0liz%C3%A6ti%C3%B8n++-++is+the+greatest%21+'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   17     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'slugify'
          8        SEND_VAL                                                 '+%5E%2A_%3A%E9%A6%99%E6%B8%AF+%C3%A5%C3%A4%3F%C3%B6+'
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
   18    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'slugify'
         14        SEND_VAL                                                 '%CF%84%CF%89%CE%BD+%CF%85%CE%B9%CF%8E%CE%BD'
         15        DO_FCALL                                      0  $4      
         16        SEND_VAR                                                 $4
         17        DO_ICALL                                                 
   19    18        INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'slugify'
         20        SEND_VAL                                                 '%CE%95%CE%BB%CE%BB%CE%B7%CE%BD%CE%B9%CE%BA%CE%AE+%CE%94%CE%B7%CE%BC%CE%BF%CE%BA%CF%81%CE%B1%CF%84%CE%AF%CE%B1'
         21        DO_FCALL                                      0  $6      
         22        SEND_VAR                                                 $6
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Function slugify:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 31
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
Branch analysis from position: 12
filename:       /in/lcChO
function name:  slugify
number of ops:  46
compiled vars:  !0 = $str, !1 = $maxLength, !2 = $separator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      '-'
    4     3        INIT_FCALL                                               'function_exists'
          4        SEND_VAL                                                 'transliterator_transliterate'
          5        DO_ICALL                                         $3      
          6      > JMPZ                                                     $3, ->12
    5     7    >   INIT_FCALL_BY_NAME                                       'transliterator_transliterate'
          8        SEND_VAL_EX                                              'Any-Latin%3B+Latin-ASCII%3B+Lower%28%29'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0  $4      
         11        ASSIGN                                                   !0, $4
    7    12    >   INIT_FCALL_BY_NAME                                       'iconv'
         13        SEND_VAL_EX                                              'UTF-8'
         14        SEND_VAL_EX                                              'ASCII%2F%2FTRANSLIT%2F%2FIGNORE'
         15        SEND_VAR_EX                                              !0
         16        DO_FCALL                                      0  $6      
         17        ASSIGN                                                   !0, $6
    8    18        INIT_FCALL                                               'preg_replace'
         19        SEND_VAL                                                 '%2F%5B%5Ea-zA-Z0-9%5C%2F_%7C%27%5C.+-%5D%2F'
         20        SEND_VAL                                                 ''
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $8      
         23        ASSIGN                                                   !0, $8
    9    24        TYPE_CHECK                                  1020          !1
         25      > JMPZ                                                     ~10, ->31
   10    26    >   INIT_FCALL                                               'substr'
         27        SEND_VAR                                                 !0
         28        SEND_VAL                                                 0
         29        SEND_VAR                                                 !1
         30        DO_ICALL                                                 
   12    31    >   INIT_FCALL                                               'preg_replace'
         32        SEND_VAL                                                 '%2F%5B%5C%2F_%7C+-%5D%2B%2F'
         33        SEND_VAR                                                 !2
         34        SEND_VAR                                                 !0
         35        DO_ICALL                                         $12     
         36        ASSIGN                                                   !0, $12
   13    37        INIT_FCALL                                               'trim'
         38        INIT_FCALL                                               'strtolower'
         39        SEND_VAR                                                 !0
         40        DO_ICALL                                         $14     
         41        SEND_VAR                                                 $14
         42        SEND_VAR                                                 !2
         43        DO_ICALL                                         $15     
         44      > RETURN                                                   $15
   14    45*     > RETURN                                                   null

End of function slugify

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.66 ms | 1407 KiB | 29 Q