3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = " <div id='div-gpt-ad-1456499310532-2' style='height:90px; width:970px;' style=\"height:90px; width:970px;\"> </div>"; // create a new DomDocument object $doc = new DOMDocument(); // load the HTML into the DomDocument object (this would be your source HTML) $doc->loadHTML($input); removeElementsByTagName('style', $doc); // output cleaned html echo $doc->saveHtml(); function removeElementsByTagName($tagName, $document) { $nodeList = $document->getElementsByTagName($tagName); for ($nodeIdx = $nodeList->length; --$nodeIdx >= 0; ) { $node = $nodeList->item($nodeIdx); $node->parentNode->removeChild($node); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/an1lk
function name:  (null)
number of ops:  15
compiled vars:  !0 = $input, !1 = $doc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%0A%3Cdiv+id%3D%27div-gpt-ad-1456499310532-2%27+style%3D%27height%3A90px%3B+width%3A970px%3B%27+style%3D%22height%3A90px%3B+width%3A970px%3B%22%3E%0A%3C%2Fdiv%3E'
    8     1        NEW                                              $3      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $3
   11     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   13     7        INIT_FCALL_BY_NAME                                       'removeElementsByTagName'
          8        SEND_VAL_EX                                              'style'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0          
   16    11        INIT_METHOD_CALL                                         !1, 'saveHtml'
         12        DO_FCALL                                      0  $8      
         13        ECHO                                                     $8
   24    14      > RETURN                                                   1

Function removeelementsbytagname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 9
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 9
Branch analysis from position: 20
Branch analysis from position: 9
filename:       /in/an1lk
function name:  removeElementsByTagName
number of ops:  21
compiled vars:  !0 = $tagName, !1 = $document, !2 = $nodeList, !3 = $nodeIdx, !4 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !2, $5
   20     6        FETCH_OBJ_R                                      ~7      !2, 'length'
          7        ASSIGN                                                   !3, ~7
          8      > JMP                                                      ->17
   21     9    >   INIT_METHOD_CALL                                         !2, 'item'
         10        SEND_VAR_EX                                              !3
         11        DO_FCALL                                      0  $9      
         12        ASSIGN                                                   !4, $9
   22    13        FETCH_OBJ_R                                      ~11     !4, 'parentNode'
         14        INIT_METHOD_CALL                                         ~11, 'removeChild'
         15        SEND_VAR_EX                                              !4
         16        DO_FCALL                                      0          
   20    17    >   PRE_DEC                                          ~13     !3
         18        IS_SMALLER_OR_EQUAL                                      0, ~13
         19      > JMPNZ                                                    ~14, ->9
   24    20    > > RETURN                                                   null

End of function removeelementsbytagname

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.8 ms | 1399 KiB | 13 Q