3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <!DOCTYPE HTML> <html> <body> <div></div> </body> </html> HTML; $dom = new DOMDocument(); $dom->loadHTML($html); $divs = iterator_to_array($dom->getElementsByTagName('div')->getIterator()); foreach ($divs as $div) { $fragment = $dom->createDocumentFragment(); $fragment->appendXML('<p>Hi!</p>'); $div->replaceWith(...$fragment->childNodes); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 30
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 30
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/AgHLn
function name:  (null)
number of ops:  32
compiled vars:  !0 = $html, !1 = $dom, !2 = $divs, !3 = $div, !4 = $fragment
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3C%21DOCTYPE+HTML%3E%0A%3Chtml%3E%0A%3Cbody%3E%0A++++%3Cdiv%3E%3C%2Fdiv%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   12     1        NEW                                              $6      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
   13     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   15     7        INIT_FCALL                                               'iterator_to_array'
          8        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          9        SEND_VAL_EX                                              'div'
         10        DO_FCALL                                      0  $10     
         11        INIT_METHOD_CALL                                         $10, 'getIterator'
         12        DO_FCALL                                      0  $11     
         13        SEND_VAR                                                 $11
         14        DO_ICALL                                         $12     
         15        ASSIGN                                                   !2, $12
   16    16      > FE_RESET_R                                       $14     !2, ->30
         17    > > FE_FETCH_R                                               $14, !3, ->30
   17    18    >   INIT_METHOD_CALL                                         !1, 'createDocumentFragment'
         19        DO_FCALL                                      0  $15     
         20        ASSIGN                                                   !4, $15
   18    21        INIT_METHOD_CALL                                         !4, 'appendXML'
         22        SEND_VAL_EX                                              '%3Cp%3EHi%21%3C%2Fp%3E'
         23        DO_FCALL                                      0          
   19    24        INIT_METHOD_CALL                                         !3, 'replaceWith'
         25        FETCH_OBJ_R                                      ~18     !4, 'childNodes'
         26        SEND_UNPACK                                              ~18
         27        CHECK_UNDEF_ARGS                                         
         28        DO_FCALL                                      1          
   16    29      > JMP                                                      ->17
         30    >   FE_FREE                                                  $14
   20    31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.84 ms | 1001 KiB | 14 Q