3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getSlug($cadena, $separador='-') { // Eliminamos el separador si ya existe en la cadana actual $cadena = str_replace($separador, "",$cadena); // Convertimos la cadena a minúsculas $cadena = strtolower($cadena); // Remplazamos tildes y eñes (strtolower no convierte en minúsculas // estos valores así que cambiamos sus respectivas mayúsculas en // minúsculas sin tilde) $cadena = strtr($cadena, "áéíóúÁÉÍÓÚñÑ", "aeiouaeiounn"); // Eliminamos cuarquier carácter no alfamnumérico $cadena = trim(preg_replace("/[^ a-z0-9]/", "", $cadena)); // Insertamos el separador $cadena = preg_replace("/[ \t\n\r]+/", $separador, $cadena); return $cadena; } echo getSlug('holaccdd');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DItmG
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'getslug'
          1        SEND_VAL                                                 'holaccdd'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function getslug:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DItmG
function name:  getSlug
number of ops:  35
compiled vars:  !0 = $cadena, !1 = $separador
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      '-'
    4     2        INIT_FCALL                                               'str_replace'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 ''
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7        ASSIGN                                                   !0, $2
    6     8        INIT_FCALL                                               'strtolower'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $4      
         11        ASSIGN                                                   !0, $4
   10    12        INIT_FCALL                                               'strtr'
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 '%C3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%81%C3%89%C3%8D%C3%93%C3%9A%C3%B1%C3%91'
         15        SEND_VAL                                                 'aeiouaeiounn'
         16        DO_ICALL                                         $6      
         17        ASSIGN                                                   !0, $6
   12    18        INIT_FCALL                                               'trim'
         19        INIT_FCALL                                               'preg_replace'
         20        SEND_VAL                                                 '%2F%5B%5E+a-z0-9%5D%2F'
         21        SEND_VAL                                                 ''
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $8      
         24        SEND_VAR                                                 $8
         25        DO_ICALL                                         $9      
         26        ASSIGN                                                   !0, $9
   14    27        INIT_FCALL                                               'preg_replace'
         28        SEND_VAL                                                 '%2F%5B+%09%0A%0D%5D%2B%2F'
         29        SEND_VAR                                                 !1
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                         $11     
         32        ASSIGN                                                   !0, $11
   16    33      > RETURN                                                   !0
   17    34*     > RETURN                                                   null

End of function getslug

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.95 ms | 1403 KiB | 24 Q