3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '<div id="parent"> <div class="box1"> content 1</div> <div class="box2"> content 1</div> <div class="box3"> content 1 <div class="box31"></div></div> </div>'; $dom = new DOMDocument; $dom->loadHTML($string); $xpath = new DOMXPath($dom); $parentNode = $xpath->query("//div[@id='parent']"); $childrenNodes = $parentNode->item(0)->childNodes; $html = ''; foreach ($childrenNodes as $node) { $html .= $node->ownerDocument->saveHtml($node); } echo $html;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 29
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 29
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/94DEQ
function name:  (null)
number of ops:  32
compiled vars:  !0 = $string, !1 = $dom, !2 = $xpath, !3 = $parentNode, !4 = $childrenNodes, !5 = $html, !6 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv+id%3D%22parent%22%3E%0A++++++%3Cdiv+class%3D%22box1%22%3E+content+1%3C%2Fdiv%3E%0A++++++%3Cdiv+class%3D%22box2%22%3E+content+1%3C%2Fdiv%3E%0A++++++%3Cdiv+class%3D%22box3%22%3E+content+1+%3Cdiv+class%3D%22box31%22%3E%3C%2Fdiv%3E%3C%2Fdiv%3E%0A%3C%2Fdiv%3E'
    9     1        NEW                                              $8      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $8
   10     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   12     7        NEW                                              $12     'DOMXPath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $12
   13    11        INIT_METHOD_CALL                                         !2, 'query'
         12        SEND_VAL_EX                                              '%2F%2Fdiv%5B%40id%3D%27parent%27%5D'
         13        DO_FCALL                                      0  $15     
         14        ASSIGN                                                   !3, $15
   16    15        INIT_METHOD_CALL                                         !3, 'item'
         16        SEND_VAL_EX                                              0
         17        DO_FCALL                                      0  $17     
         18        FETCH_OBJ_R                                      ~18     $17, 'childNodes'
         19        ASSIGN                                                   !4, ~18
   17    20        ASSIGN                                                   !5, ''
   18    21      > FE_RESET_R                                       $21     !4, ->29
         22    > > FE_FETCH_R                                               $21, !6, ->29
   19    23    >   FETCH_OBJ_R                                      ~22     !6, 'ownerDocument'
         24        INIT_METHOD_CALL                                         ~22, 'saveHtml'
         25        SEND_VAR_EX                                              !6
         26        DO_FCALL                                      0  $23     
         27        ASSIGN_OP                                     8          !5, $23
   18    28      > JMP                                                      ->22
         29    >   FE_FREE                                                  $21
   22    30        ECHO                                                     !5
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.54 ms | 1399 KiB | 13 Q