3v4l.org

run code in 300+ PHP versions simultaneously
<?php function slug($title, $separator = '-') { // Remove all characters that are not the separator, letters, numbers, or whitespace. $title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title)); // Convert all dashes/undescores into separator $flip = $separator == '-' ? '_' : '-'; $title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title); // Replace all separator characters and whitespace by a single separator $title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title); return trim($title, $separator); } slug('https://eu.api.battle.net/wow/battlePet/ability/640');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HYJhX
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'slug'
          1        SEND_VAL                                                 'https%3A%2F%2Feu.api.battle.net%2Fwow%2FbattlePet%2Fability%2F640'
          2        DO_FCALL                                      0          
          3      > RETURN                                                   1

Function slug:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HYJhX
function name:  slug
number of ops:  50
compiled vars:  !0 = $title, !1 = $separator, !2 = $flip
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      '-'
    5     2        INIT_FCALL                                               'preg_replace'
          3        INIT_FCALL                                               'preg_quote'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $3      
          6        CONCAT                                           ~4      '%21%5B%5E', $3
          7        CONCAT                                           ~5      ~4, '%5CpL%5CpN%5Cs%5D%2B%21u'
          8        SEND_VAL                                                 ~5
          9        SEND_VAL                                                 ''
         10        INIT_FCALL                                               'mb_strtolower'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $6      
         13        SEND_VAR                                                 $6
         14        DO_ICALL                                         $7      
         15        ASSIGN                                                   !0, $7
    8    16        IS_EQUAL                                                 !1, '-'
         17      > JMPZ                                                     ~9, ->20
         18    >   QM_ASSIGN                                        ~10     '_'
         19      > JMP                                                      ->21
         20    >   QM_ASSIGN                                        ~10     '-'
         21    >   ASSIGN                                                   !2, ~10
   10    22        INIT_FCALL                                               'preg_replace'
         23        INIT_FCALL                                               'preg_quote'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                         $12     
         26        CONCAT                                           ~13     '%21%5B', $12
         27        CONCAT                                           ~14     ~13, '%5D%2B%21u'
         28        SEND_VAL                                                 ~14
         29        SEND_VAR                                                 !1
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                         $15     
         32        ASSIGN                                                   !0, $15
   13    33        INIT_FCALL                                               'preg_replace'
         34        INIT_FCALL                                               'preg_quote'
         35        SEND_VAR                                                 !1
         36        DO_ICALL                                         $17     
         37        CONCAT                                           ~18     '%21%5B', $17
         38        CONCAT                                           ~19     ~18, '%5Cs%5D%2B%21u'
         39        SEND_VAL                                                 ~19
         40        SEND_VAR                                                 !1
         41        SEND_VAR                                                 !0
         42        DO_ICALL                                         $20     
         43        ASSIGN                                                   !0, $20
   15    44        INIT_FCALL                                               'trim'
         45        SEND_VAR                                                 !0
         46        SEND_VAR                                                 !1
         47        DO_ICALL                                         $22     
         48      > RETURN                                                   $22
   16    49*     > RETURN                                                   null

End of function slug

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.48 ms | 1403 KiB | 22 Q