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->parentNode->removeChild($node); } echo $dom->saveHtml($div);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 28
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 28
Branch analysis from position: 35
Branch analysis from position: 28
filename:       /in/YAgQ4
function name:  (null)
number of ops:  40
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                                                      ->33
   18    28    >   FETCH_OBJ_R                                      ~25     !7, 'parentNode'
         29        INIT_METHOD_CALL                                         ~25, 'removeChild'
         30        SEND_VAR_EX                                              !7
         31        DO_FCALL                                      0          
   17    32        PRE_DEC                                                  !6
         33    >   IS_SMALLER_OR_EQUAL                                      0, !6
         34      > JMPNZ                                                    ~28, ->28
   20    35    >   INIT_METHOD_CALL                                         !1, 'saveHtml'
         36        SEND_VAR_EX                                              !3
         37        DO_FCALL                                      0  $29     
         38        ECHO                                                     $29
         39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.17 ms | 1399 KiB | 13 Q