3v4l.org

run code in 500+ 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:  24
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                                                   'strtolower'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $2      
          4        FRAMELESS_ICALL_3                preg_replace        ~3      '%7E%5B%5Ea-z%5D%7E', '_'
          5        OP_DATA                                                      $2
          6        ECHO                                                         ~3
    4     7        ECHO                                                         '%0A%0A'
    5     8        INIT_FCALL                                                   'strtolower'
          9        SEND_VAR                                                     !0
         10        DO_ICALL                                             $4      
         11        FRAMELESS_ICALL_3                preg_replace        ~5      '%7E%5B%5Ea-z+%5D%2B%7E', ''
         12        OP_DATA                                                      $4
         13        FRAMELESS_ICALL_3                str_replace         ~6      '+', '_'
         14        OP_DATA                                                      ~5
         15        ECHO                                                         ~6
    6    16        ECHO                                                         '%0A%0A'
    7    17        INIT_FCALL                                                   'strtolower'
         18        SEND_VAR                                                     !0
         19        DO_ICALL                                             $7      
         20        FRAMELESS_ICALL_3                preg_replace        ~8      <array>, <array>
         21        OP_DATA                                                      $7
         22        ECHO                                                         ~8
         23      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.22 ms | 2209 KiB | 14 Q