3v4l.org

run code in 300+ PHP versions simultaneously
<?php $doc = "<g> <svg> <g><path/></g> <g><circle/></g> </svg> <svg> <g><circle/></g> </svg> <svg> <g><circle2/></g> </svg> </g>"; $dom = new DOMDocument(); $dom->loadXML($doc); $x = new DOMXPath($dom); $toDelete = $x->query("//svg[not(.//path)]"); foreach ($toDelete as $child) { var_dump($child); $child->parentNode->removeChild($child); } var_dump($dom->saveXML());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 25
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 25
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/6kKYI
function name:  (null)
number of ops:  32
compiled vars:  !0 = $doc, !1 = $dom, !2 = $x, !3 = $toDelete, !4 = $child
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cg%3E%0A++++%3Csvg%3E%0A++++++++%3Cg%3E%3Cpath%2F%3E%3C%2Fg%3E%0A++++++++%3Cg%3E%3Ccircle%2F%3E%3C%2Fg%3E%0A++++%3C%2Fsvg%3E%0A++++%3Csvg%3E%0A++++++++%3Cg%3E%3Ccircle%2F%3E%3C%2Fg%3E%0A++++%3C%2Fsvg%3E%0A++++%3Csvg%3E%0A++++++++%3Cg%3E%3Ccircle2%2F%3E%3C%2Fg%3E%0A++++%3C%2Fsvg%3E%0A%3C%2Fg%3E'
   16     1        NEW                                              $6      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
   17     4        INIT_METHOD_CALL                                         !1, 'loadXML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   18     7        NEW                                              $10     'DOMXPath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $10
   19    11        INIT_METHOD_CALL                                         !2, 'query'
         12        SEND_VAL_EX                                              '%2F%2Fsvg%5Bnot%28.%2F%2Fpath%29%5D'
         13        DO_FCALL                                      0  $13     
         14        ASSIGN                                                   !3, $13
   20    15      > FE_RESET_R                                       $15     !3, ->25
         16    > > FE_FETCH_R                                               $15, !4, ->25
   21    17    >   INIT_FCALL                                               'var_dump'
         18        SEND_VAR                                                 !4
         19        DO_ICALL                                                 
   22    20        FETCH_OBJ_R                                      ~17     !4, 'parentNode'
         21        INIT_METHOD_CALL                                         ~17, 'removeChild'
         22        SEND_VAR_EX                                              !4
         23        DO_FCALL                                      0          
   20    24      > JMP                                                      ->16
         25    >   FE_FREE                                                  $15
   24    26        INIT_FCALL                                               'var_dump'
         27        INIT_METHOD_CALL                                         !1, 'saveXML'
         28        DO_FCALL                                      0  $19     
         29        SEND_VAR                                                 $19
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
129.07 ms | 1401 KiB | 15 Q