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'); $elements_array = iterator_to_array($elements); foreach ($elements_array 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 = 20, Position 2 = 30
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 30
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 29
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/5ug9c
function name:  (null)
number of ops:  35
compiled vars:  !0 = $dom, !1 = $elements, !2 = $elements_array, !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        INIT_METHOD_CALL                                         !0, 'getElementsByTagName'
         12        SEND_VAL_EX                                              'element'
         13        DO_FCALL                                      0  $9      
         14        ASSIGN                                                   !1, $9
   21    15        INIT_FCALL                                               'iterator_to_array'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $11     
         18        ASSIGN                                                   !2, $11
   22    19      > FE_RESET_R                                       $13     !2, ->30
         20    > > FE_FETCH_R                                               $13, !3, ->30
   24    21    >   INIT_METHOD_CALL                                         !3, 'hasAttribute'
         22        SEND_VAL_EX                                              'attr'
         23        DO_FCALL                                      0  $14     
         24      > JMPZ                                                     $14, ->29
   25    25    >   FETCH_OBJ_R                                      ~15     !3, 'parentNode'
         26        INIT_METHOD_CALL                                         ~15, 'removeChild'
         27        SEND_VAR_EX                                              !3
         28        DO_FCALL                                      0          
   22    29    > > JMP                                                      ->20
         30    >   FE_FREE                                                  $13
   29    31        INIT_METHOD_CALL                                         !0, 'saveXML'
         32        DO_FCALL                                      0  $17     
         33        ECHO                                                     $17
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.56 ms | 1400 KiB | 17 Q