3v4l.org

run code in 300+ PHP versions simultaneously
<?php header('Content-Type: text/plain; charset="utf-8"'); $dom = new DOMDocument('1.0', 'UTF-8'); $dom->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 ); $elements = $dom->getElementsByTagName('element'); foreach (iterator_to_array($elements) as $element) { /** @var $element DomElement */ if ($element->hasAttribute('attr')) { $element->parentNode->removeChild($element); } } echo $dom->saveXML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 29
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 29
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 28
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/ieN3X
function name:  (null)
number of ops:  34
compiled vars:  !0 = $dom, !1 = $elements, !2 = $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                                              $4      'DOMDocument'
          4        SEND_VAL_EX                                              '1.0'
          5        SEND_VAL_EX                                              'UTF-8'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $4
    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        INIT_METHOD_CALL                                         !0, 'getElementsByTagName'
         12        SEND_VAL_EX                                              'element'
         13        DO_FCALL                                      0  $8      
         14        ASSIGN                                                   !1, $8
   22    15        INIT_FCALL                                               'iterator_to_array'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $10     
         18      > FE_RESET_R                                       $11     $10, ->29
         19    > > FE_FETCH_R                                               $11, !2, ->29
   24    20    >   INIT_METHOD_CALL                                         !2, 'hasAttribute'
         21        SEND_VAL_EX                                              'attr'
         22        DO_FCALL                                      0  $12     
         23      > JMPZ                                                     $12, ->28
   25    24    >   FETCH_OBJ_R                                      ~13     !2, 'parentNode'
         25        INIT_METHOD_CALL                                         ~13, 'removeChild'
         26        SEND_VAR_EX                                              !2
         27        DO_FCALL                                      0          
   22    28    > > JMP                                                      ->19
         29    >   FE_FREE                                                  $11
   29    30        INIT_METHOD_CALL                                         !0, 'saveXML'
         31        DO_FCALL                                      0  $15     
         32        ECHO                                                     $15
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.08 ms | 1400 KiB | 17 Q