3v4l.org

run code in 300+ PHP versions simultaneously
<?php function createSlug($str, $replace=array(), $delimiter='-') { setlocale(LC_ALL, 'en_US.UTF8'); if( !empty($replace) ) { $str = str_replace((array)$replace, ' ', $str); } $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str); $clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean); $clean = strtolower(trim($clean, '-')); $clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean); //strip extra slashes $clean = str_replace('/', '-', $clean); return $clean; } echo createSlug("Abbaye de Saint-Martin Cuvée de Noël.");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B1UEc
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'createslug'
          1        SEND_VAL                                                 'Abbaye+de+Saint-Martin+Cuv%C3%A9e+de+No%C3%ABl.'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function createslug:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/B1UEc
function name:  createSlug
number of ops:  51
compiled vars:  !0 = $str, !1 = $replace, !2 = $delimiter, !3 = $clean
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
          2        RECV_INIT                                        !2      '-'
    4     3        INIT_FCALL                                               'setlocale'
          4        SEND_VAL                                                 6
          5        SEND_VAL                                                 'en_US.UTF8'
          6        DO_ICALL                                                 
    5     7        ISSET_ISEMPTY_CV                                 ~5      !1
          8        BOOL_NOT                                         ~6      ~5
          9      > JMPZ                                                     ~6, ->17
    6    10    >   INIT_FCALL                                               'str_replace'
         11        CAST                                          7  ~7      !1
         12        SEND_VAL                                                 ~7
         13        SEND_VAL                                                 '+'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $8      
         16        ASSIGN                                                   !0, $8
    8    17    >   INIT_FCALL_BY_NAME                                       'iconv'
         18        SEND_VAL_EX                                              'UTF-8'
         19        SEND_VAL_EX                                              'ASCII%2F%2FTRANSLIT'
         20        SEND_VAR_EX                                              !0
         21        DO_FCALL                                      0  $10     
         22        ASSIGN                                                   !3, $10
    9    23        INIT_FCALL                                               'preg_replace'
         24        SEND_VAL                                                 '%2F%5B%5Ea-zA-Z0-9%5C%2F_%7C%2B+-%5D%2F'
         25        SEND_VAL                                                 ''
         26        SEND_VAR                                                 !3
         27        DO_ICALL                                         $12     
         28        ASSIGN                                                   !3, $12
   10    29        INIT_FCALL                                               'strtolower'
         30        INIT_FCALL                                               'trim'
         31        SEND_VAR                                                 !3
         32        SEND_VAL                                                 '-'
         33        DO_ICALL                                         $14     
         34        SEND_VAR                                                 $14
         35        DO_ICALL                                         $15     
         36        ASSIGN                                                   !3, $15
   11    37        INIT_FCALL                                               'preg_replace'
         38        SEND_VAL                                                 '%2F%5B%5C%2F_%7C%2B+-%5D%2B%2F'
         39        SEND_VAR                                                 !2
         40        SEND_VAR                                                 !3
         41        DO_ICALL                                         $17     
         42        ASSIGN                                                   !3, $17
   13    43        INIT_FCALL                                               'str_replace'
         44        SEND_VAL                                                 '%2F'
         45        SEND_VAL                                                 '-'
         46        SEND_VAR                                                 !3
         47        DO_ICALL                                         $19     
         48        ASSIGN                                                   !3, $19
   14    49      > RETURN                                                   !3
   15    50*     > RETURN                                                   null

End of function createslug

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.94 ms | 1403 KiB | 24 Q