3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <div> <div class="coincodex-content"> hello this is content <div class="delete_this" style="margin: 8px 0; clear: both;"> <div> <center><span style="font-size:11px; color: gray;">TEST</span></center> <b>TEST</b><br><br> </div> </div> <div class="preserved"> Test2 </div> </div> </div> HTML; $doc = new DOMDocument(); $doc->loadHTML($html); $xpath = new DOMXPath($doc); $nodelist = $xpath->query( '//*[@class="coincodex-content"]' ); $fragment = []; foreach($nodelist as $contentNode){ $removeNodelist = $xpath->query('//div[@class="delete_this"]',$contentNode); $item = $removeNodelist->item(0); //only first $item->parentNode->removeChild($item); $fragment[] = $doc->saveHTML($contentNode); } echo $fragment[0];
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 37
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 37
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/QP5jk
function name:  (null)
number of ops:  41
compiled vars:  !0 = $html, !1 = $doc, !2 = $xpath, !3 = $nodelist, !4 = $fragment, !5 = $contentNode, !6 = $removeNodelist, !7 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv%3E%0A%3Cdiv+class%3D%22coincodex-content%22%3E%0Ahello+this+is+content%0A++%3Cdiv+class%3D%22delete_this%22+style%3D%22margin%3A+8px+0%3B+clear%3A+both%3B%22%3E%0A++++%3Cdiv%3E%0A+++++++%3Ccenter%3E%3Cspan+style%3D%22font-size%3A11px%3B+color%3A+gray%3B%22%3ETEST%3C%2Fspan%3E%3C%2Fcenter%3E%0A+++++++%3Cb%3ETEST%3C%2Fb%3E%3Cbr%3E%3Cbr%3E%0A+++++%3C%2Fdiv%3E%0A++%3C%2Fdiv%3E%0A++%3Cdiv+class%3D%22preserved%22%3E%0A++++Test2%0A++%3C%2Fdiv%3E%0A%3C%2Fdiv%3E%0A%3C%2Fdiv%3E'
   20     1        NEW                                              $9      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $9
   21     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   22     7        NEW                                              $13     'DOMXPath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $13
   23    11        INIT_METHOD_CALL                                         !2, 'query'
         12        SEND_VAL_EX                                              '%2F%2F%2A%5B%40class%3D%22coincodex-content%22%5D'
         13        DO_FCALL                                      0  $16     
         14        ASSIGN                                                   !3, $16
   24    15        ASSIGN                                                   !4, <array>
   25    16      > FE_RESET_R                                       $19     !3, ->37
         17    > > FE_FETCH_R                                               $19, !5, ->37
   26    18    >   INIT_METHOD_CALL                                         !2, 'query'
         19        SEND_VAL_EX                                              '%2F%2Fdiv%5B%40class%3D%22delete_this%22%5D'
         20        SEND_VAR_EX                                              !5
         21        DO_FCALL                                      0  $20     
         22        ASSIGN                                                   !6, $20
   27    23        INIT_METHOD_CALL                                         !6, 'item'
         24        SEND_VAL_EX                                              0
         25        DO_FCALL                                      0  $22     
         26        ASSIGN                                                   !7, $22
   28    27        FETCH_OBJ_R                                      ~24     !7, 'parentNode'
         28        INIT_METHOD_CALL                                         ~24, 'removeChild'
         29        SEND_VAR_EX                                              !7
         30        DO_FCALL                                      0          
   29    31        INIT_METHOD_CALL                                         !1, 'saveHTML'
         32        SEND_VAR_EX                                              !5
         33        DO_FCALL                                      0  $27     
         34        ASSIGN_DIM                                               !4
         35        OP_DATA                                                  $27
   25    36      > JMP                                                      ->17
         37    >   FE_FREE                                                  $19
   32    38        FETCH_DIM_R                                      ~28     !4, 0
         39        ECHO                                                     ~28
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.54 ms | 1004 KiB | 13 Q