3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '<p class="example">example</p> <p class="example" style="visibility:hidden">example</p> <script type="text/javascript">var example = 1 ....other stuff.... </script>'; $arr = explode(PHP_EOL, $str); //var_dump($arr); for($i = 0; $i < count($arr); $i++){ if(strpos("hidden", $arr[$i]) === false){ echo $arr[$i]; unset($arr[$i]); } if(strpos("<script", $arr[$i]) === false){ while(!strpos("</script", $arr[$i]) === false){ unset($arr[$i]); $i++; } } } $str = implode(PHP_EOL, $arr); echo $str; Echo substr_count(strip_tags($str), "example");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 8
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 36
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 26
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 8
Branch analysis from position: 40
Branch analysis from position: 8
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 26
Branch analysis from position: 36
Branch analysis from position: 26
Branch analysis from position: 36
Branch analysis from position: 18
filename:       /in/L301T
function name:  (null)
number of ops:  55
compiled vars:  !0 = $str, !1 = $arr, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cp+class%3D%22example%22%3Eexample%3C%2Fp%3E%0A+++%3Cp+class%3D%22example%22+style%3D%22visibility%3Ahidden%22%3Eexample%3C%2Fp%3E%0A+++%3Cscript+type%3D%22text%2Fjavascript%22%3Evar+example+%3D+1+%0A+++....other+stuff....%0A+++%3C%2Fscript%3E'
    9     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%0A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
   11     6        ASSIGN                                                   !2, 0
          7      > JMP                                                      ->37
   13     8    >   INIT_FCALL                                               'strpos'
          9        SEND_VAL                                                 'hidden'
         10        FETCH_DIM_R                                      ~7      !1, !2
         11        SEND_VAL                                                 ~7
         12        DO_ICALL                                         $8      
         13        TYPE_CHECK                                    4          $8
         14      > JMPZ                                                     ~9, ->18
   14    15    >   FETCH_DIM_R                                      ~10     !1, !2
         16        ECHO                                                     ~10
   15    17        UNSET_DIM                                                !1, !2
   17    18    >   INIT_FCALL                                               'strpos'
         19        SEND_VAL                                                 '%3Cscript'
         20        FETCH_DIM_R                                      ~11     !1, !2
         21        SEND_VAL                                                 ~11
         22        DO_ICALL                                         $12     
         23        TYPE_CHECK                                    4          $12
         24      > JMPZ                                                     ~13, ->36
   18    25    > > JMP                                                      ->28
   19    26    >   UNSET_DIM                                                !1, !2
   20    27        PRE_INC                                                  !2
   18    28    >   INIT_FCALL                                               'strpos'
         29        SEND_VAL                                                 '%3C%2Fscript'
         30        FETCH_DIM_R                                      ~15     !1, !2
         31        SEND_VAL                                                 ~15
         32        DO_ICALL                                         $16     
         33        BOOL_NOT                                         ~17     $16
         34        TYPE_CHECK                                    4          ~17
         35      > JMPNZ                                                    ~18, ->26
   11    36    >   PRE_INC                                                  !2
         37    >   COUNT                                            ~20     !1
         38        IS_SMALLER                                               !2, ~20
         39      > JMPNZ                                                    ~21, ->8
   24    40    >   INIT_FCALL                                               'implode'
         41        SEND_VAL                                                 '%0A'
         42        SEND_VAR                                                 !1
         43        DO_ICALL                                         $22     
         44        ASSIGN                                                   !0, $22
   25    45        ECHO                                                     !0
   26    46        INIT_FCALL                                               'substr_count'
         47        INIT_FCALL                                               'strip_tags'
         48        SEND_VAR                                                 !0
         49        DO_ICALL                                         $24     
         50        SEND_VAR                                                 $24
         51        SEND_VAL                                                 'example'
         52        DO_ICALL                                         $25     
         53        ECHO                                                     $25
         54      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
194.57 ms | 1405 KiB | 23 Q