3v4l.org

run code in 300+ PHP versions simultaneously
<?php function Slug($string){ $result = preg_replace("/[^A-Za-z0-9./\-_~]/", '', $string); return $result; /*return trim(preg_replace('~[^0-9a-zA-Z]+~i', '-', html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($string, ENT_QUOTES, 'UTF-8')), ENT_QUOTES, 'UTF-8')), '-');*/ } $user = 'Cómo hablar en sílabas'; var_dump(Slug($user)); // como-hablar-en-silabas $user = 'Álix Ãxel'; var_dump(Slug($user)); // alix-axel $user = 'Álix----_Ãxel!?!?'; var_dump(Slug($user)); // alix-axel
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/piu5A
function name:  (null)
number of ops:  22
compiled vars:  !0 = $user
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, 'C%C3%B3mo+hablar+en+s%C3%ADlabas'
   14     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'slug'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
   16     7        ASSIGN                                                   !0, '%C3%81lix+%C3%83xel'
   17     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL                                               'slug'
         10        SEND_VAR                                                 !0
         11        DO_FCALL                                      0  $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                                 
   19    14        ASSIGN                                                   !0, '%C3%81lix----_%C3%83xel%21%3F%21%3F'
   20    15        INIT_FCALL                                               'var_dump'
         16        INIT_FCALL                                               'slug'
         17        SEND_VAR                                                 !0
         18        DO_FCALL                                      0  $8      
         19        SEND_VAR                                                 $8
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Function slug:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/piu5A
function name:  Slug
number of ops:  9
compiled vars:  !0 = $string, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%2F%5B%5EA-Za-z0-9.%2F%5C-_%7E%5D%2F'
          3        SEND_VAL                                                 ''
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        ASSIGN                                                   !1, $2
    7     7      > RETURN                                                   !1
   11     8*     > RETURN                                                   null

End of function slug

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
187.15 ms | 1399 KiB | 20 Q