3v4l.org

run code in 300+ PHP versions simultaneously
<?php function make_post_type($s) { preg_match_all("~({[^{}]*}|\[[^][]*])|[\w\s]+~", $s, $m); $s = ''; foreach($m[0] as $k => $v) { $s .= (bool) $m[1][$k] ? substr($v, 1, -1) : strtolower($v); } return preg_replace('~[-\s]+~', '_', $s); } echo make_post_type("[ABC] This & Text");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QKggD
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'make_post_type'
          1        SEND_VAL                                                 '%5BABC%5D+This+%26+Text'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function make_post_type:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 28
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 28
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/QKggD
function name:  make_post_type
number of ops:  36
compiled vars:  !0 = $s, !1 = $m, !2 = $v, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%7E%28%7B%5B%5E%7B%7D%5D%2A%7D%7C%5C%5B%5B%5E%5D%5B%5D%2A%5D%29%7C%5B%5Cw%5Cs%5D%2B%7E'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                                 
    5     6        ASSIGN                                                   !0, ''
    6     7        FETCH_DIM_R                                      ~6      !1, 0
          8      > FE_RESET_R                                       $7      ~6, ->28
          9    > > FE_FETCH_R                                       ~8      $7, !2, ->28
         10    >   ASSIGN                                                   !3, ~8
    7    11        FETCH_DIM_R                                      ~10     !1, 1
         12        FETCH_DIM_R                                      ~11     ~10, !3
         13        BOOL                                             ~12     ~11
         14      > JMPZ                                                     ~12, ->22
         15    >   INIT_FCALL                                               'substr'
         16        SEND_VAR                                                 !2
         17        SEND_VAL                                                 1
         18        SEND_VAL                                                 -1
         19        DO_ICALL                                         $13     
         20        QM_ASSIGN                                        ~14     $13
         21      > JMP                                                      ->26
         22    >   INIT_FCALL                                               'strtolower'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                         $15     
         25        QM_ASSIGN                                        ~14     $15
         26    >   ASSIGN_OP                                     8          !0, ~14
    6    27      > JMP                                                      ->9
         28    >   FE_FREE                                                  $7
    9    29        INIT_FCALL                                               'preg_replace'
         30        SEND_VAL                                                 '%7E%5B-%5Cs%5D%2B%7E'
         31        SEND_VAL                                                 '_'
         32        SEND_VAR                                                 !0
         33        DO_ICALL                                         $17     
         34      > RETURN                                                   $17
   10    35*     > RETURN                                                   null

End of function make_post_type

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.89 ms | 1021 KiB | 18 Q