3v4l.org

run code in 300+ PHP versions simultaneously
<?php function item_slug($string){ return preg_replace(array('/[^A-Za-z0-9 -]+/','/[ -]+/'), array('','-'),$string); } $strings = [ "example---a-digital-product..", "Example - A digital product" ]; foreach ($strings as $str) { echo item_slug($str) . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 9
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/LGAs3
function name:  (null)
number of ops:  11
compiled vars:  !0 = $strings, !1 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, <array>
   12     1      > FE_RESET_R                                       $3      !0, ->9
          2    > > FE_FETCH_R                                               $3, !1, ->9
   13     3    >   INIT_FCALL                                               'item_slug'
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $4      
          6        CONCAT                                           ~5      $4, '%0A'
          7        ECHO                                                     ~5
   12     8      > JMP                                                      ->2
          9    >   FE_FREE                                                  $3
   14    10      > RETURN                                                   1

Function item_slug:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LGAs3
function name:  item_slug
number of ops:  8
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 <array>
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6      > RETURN                                                   $1
    5     7*     > RETURN                                                   null

End of function item_slug

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.82 ms | 1402 KiB | 16 Q