3v4l.org

run code in 300+ 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 = 47
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 40
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 40
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
Branch analysis from position: 47
filename:       /in/MBnbR
function name:  process_template
number of ops:  49
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, ->47
    5    15    >   ASSIGN                                                   !5, ''
         16        ASSIGN                                                   !6, 0
    6    17      > FE_RESET_R                                       $16     !4, ->40
         18    > > FE_FETCH_R                                               $16, !7, ->40
    7    19    >   INIT_FCALL                                               'substr'
         20        SEND_VAR                                                 !0
         21        SEND_VAR                                                 !6
         22        FETCH_DIM_R                                      ~17     !7, 0
         23        FETCH_DIM_R                                      ~18     ~17, 1
         24        SUB                                              ~19     ~18, !6
         25        SEND_VAL                                                 ~19
         26        DO_ICALL                                         $20     
         27        ASSIGN_OP                                     8          !5, $20
    8    28        FETCH_DIM_R                                      ~22     !7, 2
         29        FETCH_DIM_R                                      ~23     ~22, 0
         30        FETCH_DIM_R                                      ~24     !3, ~23
         31        ASSIGN_OP                                     8          !5, ~24
    9    32        FETCH_DIM_R                                      ~26     !7, 3
         33        FETCH_DIM_R                                      ~27     ~26, 1
         34        FETCH_DIM_R                                      ~28     !7, 3
         35        FETCH_DIM_R                                      ~29     ~28, 0
         36        STRLEN                                           ~30     ~29
         37        ADD                                              ~31     ~27, ~30
         38        ASSIGN                                                   !6, ~31
    6    39      > JMP                                                      ->18
         40    >   FE_FREE                                                  $16
   11    41        INIT_FCALL                                               'substr'
         42        SEND_VAR                                                 !0
         43        SEND_VAR                                                 !6
         44        DO_ICALL                                         $33     
         45        ASSIGN_OP                                     8          !5, $33
   12    46        ASSIGN                                                   !0, !5
   14    47    > > RETURN                                                   !0
   15    48*     > RETURN                                                   null

End of function process_template

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.42 ms | 1019 KiB | 16 Q