3v4l.org

run code in 300+ PHP versions simultaneously
<?php header('Content-Type: text/plain; charset="utf-8"'); $doc = new DOMDocument('1.0', 'UTF-8'); $doc->loadXML(<<<__XML <?xml version="1.0" encoding="UTF-8"?> <root> <element>1</element> <element attr="a">2</element> <element>3</element> <element>4</element> <element attr="a">5</element> <element attr="a">6</element> <element>7</element> <element>8</element> </root> __XML ); $xpath = new DOMXPath($doc); $elements = $xpath->query('//element[@attr]'); foreach ($elements as $element) { $element->parentNode->removeChild($element); } echo $doc->saveXML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 26
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/CM9Fv
function name:  (null)
number of ops:  31
compiled vars:  !0 = $doc, !1 = $xpath, !2 = $elements, !3 = $element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'header'
          1        SEND_VAL                                                 'Content-Type%3A+text%2Fplain%3B+charset%3D%22utf-8%22'
          2        DO_ICALL                                                 
    4     3        NEW                                              $5      'DOMDocument'
          4        SEND_VAL_EX                                              '1.0'
          5        SEND_VAL_EX                                              'UTF-8'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $5
    5     8        INIT_METHOD_CALL                                         !0, 'loadXML'
    6     9        SEND_VAL_EX                                              '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%0A%3Croot%3E%0A++++%3Celement%3E1%3C%2Felement%3E%0A++++%3Celement+attr%3D%22a%22%3E2%3C%2Felement%3E%0A++++%3Celement%3E3%3C%2Felement%3E%0A++++%3Celement%3E4%3C%2Felement%3E%0A++++%3Celement+attr%3D%22a%22%3E5%3C%2Felement%3E%0A++++%3Celement+attr%3D%22a%22%3E6%3C%2Felement%3E%0A++++%3Celement%3E7%3C%2Felement%3E%0A++++%3Celement%3E8%3C%2Felement%3E%0A%3C%2Froot%3E'
         10        DO_FCALL                                      0          
   20    11        NEW                                              $9      'DOMXPath'
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !1, $9
   21    15        INIT_METHOD_CALL                                         !1, 'query'
         16        SEND_VAL_EX                                              '%2F%2Felement%5B%40attr%5D'
         17        DO_FCALL                                      0  $12     
         18        ASSIGN                                                   !2, $12
   23    19      > FE_RESET_R                                       $14     !2, ->26
         20    > > FE_FETCH_R                                               $14, !3, ->26
   24    21    >   FETCH_OBJ_R                                      ~15     !3, 'parentNode'
         22        INIT_METHOD_CALL                                         ~15, 'removeChild'
         23        SEND_VAR_EX                                              !3
         24        DO_FCALL                                      0          
   23    25      > JMP                                                      ->20
         26    >   FE_FREE                                                  $14
   27    27        INIT_METHOD_CALL                                         !0, 'saveXML'
         28        DO_FCALL                                      0  $17     
         29        ECHO                                                     $17
         30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.08 ms | 1401 KiB | 15 Q