3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "(Here {is [a] Special} Title)! & it's fine, right?"; echo preg_replace('~[^a-z]~', '_', strtolower($string)); // all non-letters become underscores echo "\n\n"; echo str_replace(' ', '_', preg_replace('~[^a-z ]+~', '', strtolower($string))); // notice the consecutive underscores echo "\n\n"; echo preg_replace(['~[^a-z ]+~', '~ +~'], ['', '_'], strtolower($string)); // notice no consecutive underscores
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qifuC
function name:  (null)
number of ops:  36
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%28Here+%7Bis+%5Ba%5D+Special%7D+Title%29%21+%26+it%27s+fine%2C+right%3F'
    3     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%7E%5B%5Ea-z%5D%7E'
          3        SEND_VAL                                                 '_'
          4        INIT_FCALL                                               'strtolower'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                         $3      
          9        ECHO                                                     $3
    4    10        ECHO                                                     '%0A%0A'
    5    11        INIT_FCALL                                               'str_replace'
         12        SEND_VAL                                                 '+'
         13        SEND_VAL                                                 '_'
         14        INIT_FCALL                                               'preg_replace'
         15        SEND_VAL                                                 '%7E%5B%5Ea-z+%5D%2B%7E'
         16        SEND_VAL                                                 ''
         17        INIT_FCALL                                               'strtolower'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $4      
         20        SEND_VAR                                                 $4
         21        DO_ICALL                                         $5      
         22        SEND_VAR                                                 $5
         23        DO_ICALL                                         $6      
         24        ECHO                                                     $6
    6    25        ECHO                                                     '%0A%0A'
    7    26        INIT_FCALL                                               'preg_replace'
         27        SEND_VAL                                                 <array>
         28        SEND_VAL                                                 <array>
         29        INIT_FCALL                                               'strtolower'
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                         $7      
         32        SEND_VAR                                                 $7
         33        DO_ICALL                                         $8      
         34        ECHO                                                     $8
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.55 ms | 1001 KiB | 16 Q