3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <div> <div> <p> ... </p> </div> </div> HTML; $dom = new DOMDocument; $dom->loadHTML($html); $xpath = new DOMXPath($dom); $nodes = $xpath->query('//*'); foreach ($nodes as $node) { printf( "Nodes in List: %d \n" . "Current Tag: %s \n" . "Current Parent: %s \n\n", $nodes->length, $node->tagName, $node->parentNode->tagName ); $node->parentNode->removeChild($node); } echo $dom->saveHtml();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 32
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 32
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/2qC9I
function name:  (null)
number of ops:  37
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath, !3 = $nodes, !4 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv%3E%0A+++%3Cdiv%3E%0A+++++++%3Cp%3E+...+%3C%2Fp%3E%0A+++%3C%2Fdiv%3E%0A%3C%2Fdiv%3E'
   11     1        NEW                                              $6      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
   12     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   13     7        NEW                                              $10     'DOMXPath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $10
   15    11        INIT_METHOD_CALL                                         !2, 'query'
         12        SEND_VAL_EX                                              '%2F%2F%2A'
         13        DO_FCALL                                      0  $13     
         14        ASSIGN                                                   !3, $13
   16    15      > FE_RESET_R                                       $15     !3, ->32
         16    > > FE_FETCH_R                                               $15, !4, ->32
   17    17    >   INIT_FCALL                                               'printf'
   20    18        SEND_VAL                                                 'Nodes+in+List%3A+%25d+%0ACurrent+Tag%3A+%25s+%0ACurrent+Parent%3A+%25s+%0A%0A'
   21    19        FETCH_OBJ_R                                      ~16     !3, 'length'
         20        SEND_VAL                                                 ~16
   22    21        FETCH_OBJ_R                                      ~17     !4, 'tagName'
         22        SEND_VAL                                                 ~17
   23    23        FETCH_OBJ_R                                      ~18     !4, 'parentNode'
         24        FETCH_OBJ_R                                      ~19     ~18, 'tagName'
         25        SEND_VAL                                                 ~19
         26        DO_ICALL                                                 
   25    27        FETCH_OBJ_R                                      ~21     !4, 'parentNode'
         28        INIT_METHOD_CALL                                         ~21, 'removeChild'
         29        SEND_VAR_EX                                              !4
         30        DO_FCALL                                      0          
   16    31      > JMP                                                      ->16
         32    >   FE_FREE                                                  $15
   28    33        INIT_METHOD_CALL                                         !1, 'saveHtml'
         34        DO_FCALL                                      0  $23     
         35        ECHO                                                     $23
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.63 ms | 1396 KiB | 15 Q