3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myHtml = ' <html> <body> <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> </body> </html> '; $doc = new \DOMDocument(); $doc->loadHTML($myHtml, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $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 = 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/sWrUO
function name:  (null)
number of ops:  36
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%3Chtml%3E%0A%3Cbody%3E%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%3C%2Fbody%3E%0A%3C%2Fhtml%3E%0A'
   24     1        NEW                                              $7      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
   25     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              8196
          7        DO_FCALL                                      0          
   26     8        NEW                                              $11     'DOMXPath'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $11
   27    12        INIT_METHOD_CALL                                         !2, 'query'
         13        SEND_VAL_EX                                              '%2F%2Fa%5B%40title%3D%27something+something%27%5D'
         14        DO_FCALL                                      0  $14     
         15        ASSIGN                                                   !3, $14
   28    16        INIT_METHOD_CALL                                         !2, 'query'
         17        SEND_VAL_EX                                              '%2F%2Ful%5B%40class%3D%27some-class%27%5D'
         18        DO_FCALL                                      0  $16     
         19        FETCH_DIM_R                                      ~17     $16, 0
         20        ASSIGN                                                   !4, ~17
   29    21      > FE_RESET_R                                       $19     !3, ->29
         22    > > FE_FETCH_R                                               $19, !5, ->29
   30    23    >   INIT_METHOD_CALL                                         !4, 'removeChild'
         24        CHECK_FUNC_ARG                                           
         25        FETCH_OBJ_FUNC_ARG                               $20     !5, 'parentNode'
         26        SEND_FUNC_ARG                                            $20
         27        DO_FCALL                                      0          
   29    28      > JMP                                                      ->22
         29    >   FE_FREE                                                  $19
   33    30        INIT_FCALL                                               'var_dump'
         31        INIT_METHOD_CALL                                         !1, 'saveHTML'
         32        DO_FCALL                                      0  $22     
         33        SEND_VAR                                                 $22
         34        DO_ICALL                                                 
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.96 ms | 1015 KiB | 14 Q