3v4l.org

run code in 300+ PHP versions simultaneously
<?php $title = "Convert all dashes/underscores into separator"; $separator = "-"; $flip = $separator == '-' ? '_' : '-'; $title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title); // Remove all characters that are not the separator, letters, numbers, or whitespace. $title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title)); // Replace all separator characters and whitespace by a single separator $title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title); echo trim($title, $separator);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DtlCY
function name:  (null)
number of ops:  50
compiled vars:  !0 = $title, !1 = $separator, !2 = $flip
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'Convert+all+dashes%2Funderscores+into+separator'
    3     1        ASSIGN                                                   !1, '-'
    4     2        IS_EQUAL                                                 !1, '-'
          3      > JMPZ                                                     ~5, ->6
          4    >   QM_ASSIGN                                        ~6      '_'
          5      > JMP                                                      ->7
          6    >   QM_ASSIGN                                        ~6      '-'
          7    >   ASSIGN                                                   !2, ~6
    6     8        INIT_FCALL                                               'preg_replace'
          9        INIT_FCALL                                               'preg_quote'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $8      
         12        CONCAT                                           ~9      '%21%5B', $8
         13        CONCAT                                           ~10     ~9, '%5D%2B%21u'
         14        SEND_VAL                                                 ~10
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $11     
         18        ASSIGN                                                   !0, $11
    9    19        INIT_FCALL                                               'preg_replace'
         20        INIT_FCALL                                               'preg_quote'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                         $13     
         23        CONCAT                                           ~14     '%21%5B%5E', $13
         24        CONCAT                                           ~15     ~14, '%5CpL%5CpN%5Cs%5D%2B%21u'
         25        SEND_VAL                                                 ~15
         26        SEND_VAL                                                 ''
         27        INIT_FCALL                                               'mb_strtolower'
         28        SEND_VAR                                                 !0
         29        DO_ICALL                                         $16     
         30        SEND_VAR                                                 $16
         31        DO_ICALL                                         $17     
         32        ASSIGN                                                   !0, $17
   12    33        INIT_FCALL                                               'preg_replace'
         34        INIT_FCALL                                               'preg_quote'
         35        SEND_VAR                                                 !1
         36        DO_ICALL                                         $19     
         37        CONCAT                                           ~20     '%21%5B', $19
         38        CONCAT                                           ~21     ~20, '%5Cs%5D%2B%21u'
         39        SEND_VAL                                                 ~21
         40        SEND_VAR                                                 !1
         41        SEND_VAR                                                 !0
         42        DO_ICALL                                         $22     
         43        ASSIGN                                                   !0, $22
   14    44        INIT_FCALL                                               'trim'
         45        SEND_VAR                                                 !0
         46        SEND_VAR                                                 !1
         47        DO_ICALL                                         $24     
         48        ECHO                                                     $24
         49      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.67 ms | 1400 KiB | 21 Q