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('.//text()|.//@*', $div); foreach ($nodes as $node) { $node->parentNode->removeChild($node); } echo $dom->saveHtml($div);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 30
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 30
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/jhv2e
function name:  (null)
number of ops:  36
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath, !3 = $div, !4 = $nodes, !5 = $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                                              $7      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
   11     4        INIT_METHOD_CALL                                         !1, 'loadHtml'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   12     7        NEW                                              $11     'DOMXpath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $11
   14    11        INIT_METHOD_CALL                                         !2, 'evaluate'
         12        SEND_VAL_EX                                              '%2F%2Fdiv%5B%40id%3D%22makeme%22%5D'
         13        DO_FCALL                                      0  $14     
         14        INIT_METHOD_CALL                                         $14, 'item'
         15        SEND_VAL_EX                                              0
         16        DO_FCALL                                      0  $15     
         17        ASSIGN                                                   !3, $15
   15    18        INIT_METHOD_CALL                                         !2, 'evaluate'
         19        SEND_VAL_EX                                              '.%2F%2Ftext%28%29%7C.%2F%2F%40%2A'
         20        SEND_VAR_EX                                              !3
         21        DO_FCALL                                      0  $17     
         22        ASSIGN                                                   !4, $17
   16    23      > FE_RESET_R                                       $19     !4, ->30
         24    > > FE_FETCH_R                                               $19, !5, ->30
   17    25    >   FETCH_OBJ_R                                      ~20     !5, 'parentNode'
         26        INIT_METHOD_CALL                                         ~20, 'removeChild'
         27        SEND_VAR_EX                                              !5
         28        DO_FCALL                                      0          
   16    29      > JMP                                                      ->24
         30    >   FE_FREE                                                  $19
   19    31        INIT_METHOD_CALL                                         !1, 'saveHtml'
         32        SEND_VAR_EX                                              !3
         33        DO_FCALL                                      0  $22     
         34        ECHO                                                     $22
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.64 ms | 1395 KiB | 13 Q