3v4l.org

run code in 300+ PHP versions simultaneously
<?php function createSlug($str, $delimiter = '_'){ $slug = strtolower(trim(preg_replace('/[\s-]+/', $delimiter, preg_replace('/[^A-Za-z0-9-]+/', $delimiter, preg_replace('/[&]/', 'and', preg_replace('/[\']/', '', iconv('UTF-8', 'ASCII//TRANSLIT', $str))))), $delimiter)); return $slug; } print createSlug('New test field_20_ 20 New version');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mTHeM
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'createslug'
          1        SEND_VAL                                                 'New+test+field_20_+++20+New+version'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function createslug:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mTHeM
function name:  createSlug
number of ops:  37
compiled vars:  !0 = $str, !1 = $delimiter, !2 = $slug
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      '_'
    5     2        INIT_FCALL                                               'strtolower'
          3        INIT_FCALL                                               'trim'
          4        INIT_FCALL                                               'preg_replace'
          5        SEND_VAL                                                 '%2F%5B%5Cs-%5D%2B%2F'
          6        SEND_VAR                                                 !1
          7        INIT_FCALL                                               'preg_replace'
          8        SEND_VAL                                                 '%2F%5B%5EA-Za-z0-9-%5D%2B%2F'
          9        SEND_VAR                                                 !1
         10        INIT_FCALL                                               'preg_replace'
         11        SEND_VAL                                                 '%2F%5B%26%5D%2F'
         12        SEND_VAL                                                 'and'
         13        INIT_FCALL                                               'preg_replace'
         14        SEND_VAL                                                 '%2F%5B%27%5D%2F'
         15        SEND_VAL                                                 ''
         16        INIT_FCALL_BY_NAME                                       'iconv'
         17        SEND_VAL_EX                                              'UTF-8'
         18        SEND_VAL_EX                                              'ASCII%2F%2FTRANSLIT'
         19        SEND_VAR_EX                                              !0
         20        DO_FCALL                                      0  $3      
         21        SEND_VAR                                                 $3
         22        DO_ICALL                                         $4      
         23        SEND_VAR                                                 $4
         24        DO_ICALL                                         $5      
         25        SEND_VAR                                                 $5
         26        DO_ICALL                                         $6      
         27        SEND_VAR                                                 $6
         28        DO_ICALL                                         $7      
         29        SEND_VAR                                                 $7
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                         $8      
         32        SEND_VAR                                                 $8
         33        DO_ICALL                                         $9      
         34        ASSIGN                                                   !2, $9
    6    35      > RETURN                                                   !2
    8    36*     > RETURN                                                   null

End of function createslug

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.48 ms | 1403 KiB | 23 Q