3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myHtml = ' <div class="div-class"> <p>text</p> <p><a href="#">text</a></p> </div> <ul class="some-class"> <li><a href="#" target="_blank" title="something something"><img src="" alt=""></a> </li> <li><a href="" target="_blank" title=""><img src="" alt=""></a> </li> <li><a href="" target="_blank" title=""><img src=""></a> </li> </ul> '; $doc = new \DOMDocument(); $doc->loadHTML($myHtml, LIBXML_HTML_NODEFDTD); var_dump (libxml_get_errors()); $xpath = new \DOMXPath($doc); $anchors = $xpath->query("//a[@title='something something']"); $list = $xpath->query("//ul[@class='some-class']")[0]; foreach ($anchors as $a) { $list->removeChild($a->parentNode); } var_dump($doc->saveHTML());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 34
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 34
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/cGN4n
function name:  (null)
number of ops:  41
compiled vars:  !0 = $myHtml, !1 = $doc, !2 = $xpath, !3 = $anchors, !4 = $list, !5 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%0A%3Cdiv+class%3D%22div-class%22%3E%0A++++%3Cp%3Etext%3C%2Fp%3E%0A%0A++++%3Cp%3E%3Ca+href%3D%22%23%22%3Etext%3C%2Fa%3E%3C%2Fp%3E%0A%3C%2Fdiv%3E%0A%0A%3Cul+class%3D%22some-class%22%3E%0A++++%3Cli%3E%3Ca+href%3D%22%23%22+target%3D%22_blank%22+title%3D%22something+something%22%3E%3Cimg+src%3D%22%22+alt%3D%22%22%3E%3C%2Fa%3E%0A++++%3C%2Fli%3E%0A++++%3Cli%3E%3Ca+href%3D%22%22+target%3D%22_blank%22+title%3D%22%22%3E%3Cimg+src%3D%22%22+alt%3D%22%22%3E%3C%2Fa%3E%0A++++%3C%2Fli%3E%0A++++%3Cli%3E%3Ca+href%3D%22%22+target%3D%22_blank%22+title%3D%22%22%3E%3Cimg+src%3D%22%22%3E%3C%2Fa%3E%0A++++%3C%2Fli%3E%0A%3C%2Ful%3E%0A'
   20     1        NEW                                              $7      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
   21     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              4
          7        DO_FCALL                                      0          
   22     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL                                               'libxml_get_errors'
         10        DO_ICALL                                         $11     
         11        SEND_VAR                                                 $11
         12        DO_ICALL                                                 
   23    13        NEW                                              $13     'DOMXPath'
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !2, $13
   24    17        INIT_METHOD_CALL                                         !2, 'query'
         18        SEND_VAL_EX                                              '%2F%2Fa%5B%40title%3D%27something+something%27%5D'
         19        DO_FCALL                                      0  $16     
         20        ASSIGN                                                   !3, $16
   25    21        INIT_METHOD_CALL                                         !2, 'query'
         22        SEND_VAL_EX                                              '%2F%2Ful%5B%40class%3D%27some-class%27%5D'
         23        DO_FCALL                                      0  $18     
         24        FETCH_DIM_R                                      ~19     $18, 0
         25        ASSIGN                                                   !4, ~19
   26    26      > FE_RESET_R                                       $21     !3, ->34
         27    > > FE_FETCH_R                                               $21, !5, ->34
   27    28    >   INIT_METHOD_CALL                                         !4, 'removeChild'
         29        CHECK_FUNC_ARG                                           
         30        FETCH_OBJ_FUNC_ARG                               $22     !5, 'parentNode'
         31        SEND_FUNC_ARG                                            $22
         32        DO_FCALL                                      0          
   26    33      > JMP                                                      ->27
         34    >   FE_FREE                                                  $21
   30    35        INIT_FCALL                                               'var_dump'
         36        INIT_METHOD_CALL                                         !1, 'saveHTML'
         37        DO_FCALL                                      0  $24     
         38        SEND_VAR                                                 $24
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.36 ms | 1400 KiB | 17 Q