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; } slugify("João dos Santos Videira");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hl0n0
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'slugify'
          1        SEND_VAL                                                 'Jo%C3%A3o+dos+Santos+Videira'
          2        DO_FCALL                                      0          
          3      > 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/hl0n0
function name:  slugify
number of ops:  33
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
    9     7        INIT_FCALL                                               'trim'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 '-'
         10        DO_ICALL                                         $3      
         11        ASSIGN                                                   !0, $3
   12    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
   15    18        INIT_FCALL                                               'strtolower'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $7      
         21        ASSIGN                                                   !0, $7
   18    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
   20    28        ISSET_ISEMPTY_CV                                         !0
         29      > JMPZ                                                     ~11, ->31
   22    30    > > RETURN                                                   'n-a'
   25    31    > > RETURN                                                   !0
   26    32*     > RETURN                                                   null

End of function slugify

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.55 ms | 1399 KiB | 23 Q