3v4l.org

run code in 500+ PHP versions simultaneously
<?php function process_template($html,$b='<<',$e='>>'){ $replace=['this'=>'<input name="this" />','that'=>'<input name="that" />']; if(preg_match_all('/('.$b.')(.*?)('.$e.')/is',$html,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE)){ $t='';$o=0; foreach($matches as $m){ $t.=substr($html,$o,$m[0][1]-$o); $t.=$replace[$m[2][0]]; $o=$m[3][1]+strlen($m[3][0]); } $t.=substr($html,$o); $html=$t; } return $html; } $html=" <div> <<this>> <<that>> </div> "; $new=process_template($html); echo $new;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MBnbR
function name:  (null)
number of ops:  7
compiled vars:  !0 = $html, !1 = $new
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                       !0, '%0A%3Cdiv%3E%0A++++%3C%3Cthis%3E%3E%0A++++%3C%3Cthat%3E%3E%0A%3C%2Fdiv%3E%0A'
   22     1        INIT_FCALL                                                   'process_template'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $3      
          4        ASSIGN                                                       !1, $3
   23     5        ECHO                                                         !1
   24     6      > RETURN                                                       1

Function process_template:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 41
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 37
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 37
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
Branch analysis from position: 41
filename:       /in/MBnbR
function name:  process_template
number of ops:  43
compiled vars:  !0 = $html, !1 = $b, !2 = $e, !3 = $replace, !4 = $matches, !5 = $t, !6 = $o, !7 = $m
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      '%3C%3C'
          2        RECV_INIT                                            !2      '%3E%3E'
    3     3        ASSIGN                                                       !3, <array>
    4     4        INIT_FCALL                                                   'preg_match_all'
          5        CONCAT                                               ~9      '%2F%28', !1
          6        CONCAT                                               ~10     ~9, '%29%28.%2A%3F%29%28'
          7        CONCAT                                               ~11     ~10, !2
          8        CONCAT                                               ~12     ~11, '%29%2Fis'
          9        SEND_VAL                                                     ~12
         10        SEND_VAR                                                     !0
         11        SEND_REF                                                     !4
         12        SEND_VAL                                                     258
         13        DO_ICALL                                             $13     
         14      > JMPZ                                                         $13, ->41
    5    15    >   ASSIGN                                                       !5, ''
         16        ASSIGN                                                       !6, 0
    6    17      > FE_RESET_R                                           $16     !4, ->37
         18    > > FE_FETCH_R                                                   $16, !7, ->37
    7    19    >   FETCH_DIM_R                                          ~17     !7, 0
         20        FETCH_DIM_R                                          ~18     ~17, 1
         21        SUB                                                  ~19     ~18, !6
         22        FRAMELESS_ICALL_3                substr              ~20     !0, !6
         23        OP_DATA                                                      ~19
         24        ASSIGN_OP                                         8          !5, ~20
    8    25        FETCH_DIM_R                                          ~22     !7, 2
         26        FETCH_DIM_R                                          ~23     ~22, 0
         27        FETCH_DIM_R                                          ~24     !3, ~23
         28        ASSIGN_OP                                         8          !5, ~24
    9    29        FETCH_DIM_R                                          ~26     !7, 3
         30        FETCH_DIM_R                                          ~27     ~26, 1
         31        FETCH_DIM_R                                          ~28     !7, 3
         32        FETCH_DIM_R                                          ~29     ~28, 0
         33        STRLEN                                               ~30     ~29
         34        ADD                                                  ~31     ~27, ~30
         35        ASSIGN                                                       !6, ~31
    6    36      > JMP                                                          ->18
         37    >   FE_FREE                                                      $16
   11    38        FRAMELESS_ICALL_2                substr              ~33     !0, !6
         39        ASSIGN_OP                                         8          !5, ~33
   12    40        ASSIGN                                                       !0, !5
   14    41    > > RETURN                                                       !0
   15    42*     > RETURN                                                       null

End of function process_template

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.02 ms | 2064 KiB | 15 Q