3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<'HTML' <div id='makeme' class='testme'> <span id='whatspanID'>somthing</span> <p class='ptagclass'></p> </div> HTML; $dom = new DOMDocument(); $dom->loadHtml($html); $xpath = new DOMXpath($dom); $div = $xpath->evaluate('//div[@id="makeme"]')->item(0); $nodes = $xpath->evaluate('.//@*', $div); $length = count($nodes); for($i = $length - 1; $i >= 0; --$i) { $node = $nodes->item($i); $node->parentNode->removeChild($node); } echo $dom->saveHtml($div);
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 = 39, Position 2 = 28
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 28
Branch analysis from position: 39
Branch analysis from position: 28
filename:       /in/SfpEr
function name:  (null)
number of ops:  44
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath, !3 = $div, !4 = $nodes, !5 = $length, !6 = $i, !7 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv+id%3D%27makeme%27+class%3D%27testme%27%3E%0A+++%3Cspan+id%3D%27whatspanID%27%3Esomthing%3C%2Fspan%3E%0A+++%3Cp+class%3D%27ptagclass%27%3E%3C%2Fp%3E%0A%3C%2Fdiv%3E'
   10     1        NEW                                              $9      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $9
   11     4        INIT_METHOD_CALL                                         !1, 'loadHtml'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   12     7        NEW                                              $13     'DOMXpath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $13
   14    11        INIT_METHOD_CALL                                         !2, 'evaluate'
         12        SEND_VAL_EX                                              '%2F%2Fdiv%5B%40id%3D%22makeme%22%5D'
         13        DO_FCALL                                      0  $16     
         14        INIT_METHOD_CALL                                         $16, 'item'
         15        SEND_VAL_EX                                              0
         16        DO_FCALL                                      0  $17     
         17        ASSIGN                                                   !3, $17
   15    18        INIT_METHOD_CALL                                         !2, 'evaluate'
         19        SEND_VAL_EX                                              '.%2F%2F%40%2A'
         20        SEND_VAR_EX                                              !3
         21        DO_FCALL                                      0  $19     
         22        ASSIGN                                                   !4, $19
   16    23        COUNT                                            ~21     !4
         24        ASSIGN                                                   !5, ~21
   17    25        SUB                                              ~23     !5, 1
         26        ASSIGN                                                   !6, ~23
         27      > JMP                                                      ->37
   18    28    >   INIT_METHOD_CALL                                         !4, 'item'
         29        SEND_VAR_EX                                              !6
         30        DO_FCALL                                      0  $25     
         31        ASSIGN                                                   !7, $25
   19    32        FETCH_OBJ_R                                      ~27     !7, 'parentNode'
         33        INIT_METHOD_CALL                                         ~27, 'removeChild'
         34        SEND_VAR_EX                                              !7
         35        DO_FCALL                                      0          
   17    36        PRE_DEC                                                  !6
         37    >   IS_SMALLER_OR_EQUAL                                      0, !6
         38      > JMPNZ                                                    ~30, ->28
   21    39    >   INIT_METHOD_CALL                                         !1, 'saveHtml'
         40        SEND_VAR_EX                                              !3
         41        DO_FCALL                                      0  $31     
         42        ECHO                                                     $31
         43      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.72 ms | 1399 KiB | 13 Q