3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <table> <tr> <td class="adminK2LeftCol"> <label>Categoria</label> </td> <td class="adminK2RightCol"> <select id="catid" name="catid"> <option value="0">- Selecionar categoria -</option> <option style="color: rgb(128, 128, 128);" value="1" disabled="disabled">Notícias</option> <option style="color: rgb(128, 128, 128);" value="2" disabled="disabled">- - - Estado</option> <option style="color: rgb(128, 128, 128);" value="29" disabled="disabled">- - - Cultura</option> <option style="color: rgb(128, 128, 128);" value="41" disabled="disabled">- - - Nacional</option> <option style="color: rgb(128, 128, 128);" value="5" disabled="disabled">Colunas</option> <option style="color: rgb(128, 128, 128);" value="6" disabled="disabled">- - - Trocando em miúdos</option> <option style="color: rgb(128, 128, 128);" value="7" disabled="disabled">- - - Colunistas</option> <option style="color: rgb(128, 128, 128);" value="24" disabled="disabled">- - - - - Tecnologia</option> <option value="10" selected="selected">Classificados</option> <option value="30">- - - Imóveis</option> <option value="33">- - - - - Venda</option> <option style="color: rgb(128, 128, 128);" value="16" disabled="disabled">Jurídica</option> <option style="color: rgb(128, 128, 128);" value="26" disabled="disabled">Atividade parlamentar</option> <option style="color: rgb(128, 128, 128);" value="38" disabled="disabled">- - - ACOMPANHE A COBERTURA DO IMPEACHMENT</option> <option style="color: rgb(128, 128, 128);" value="39" disabled="disabled">ESPECIAL</option> <option style="color: rgb(128, 128, 128);" value="40" disabled="disabled">- - - ACOMPANHE A COBERTURA DO IMPEACHMENT</option> </select> </td> </tr> </table> HTML; libxml_use_internal_errors(true); $dom=new DOMDocument; $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); $options = $xpath->query('//option[@disabled]'); for ($i = $options->length; --$i >= 0;) { // when removing nodes from DOM, work in reverse order for stability $option = $options->item($i); $trailing_whitespace = $option->nextSibling; $option->parentNode->removeChild($option); $trailing_whitespace->parentNode->removeChild($trailing_whitespace); // optionally remove line returns after removed tags } echo $dom->saveHTML();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 22
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 22
Branch analysis from position: 39
Branch analysis from position: 22
filename:       /in/HLkAQ
function name:  (null)
number of ops:  43
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath, !3 = $options, !4 = $i, !5 = $option, !6 = $trailing_whitespace
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Ctable%3E%0A++++%3Ctr%3E%0A++++++++%3Ctd+class%3D%22adminK2LeftCol%22%3E%0A++++++++++++%3Clabel%3ECategoria%3C%2Flabel%3E%0A++++++++%3C%2Ftd%3E%0A++++++++%3Ctd+class%3D%22adminK2RightCol%22%3E%0A++++++++++++%3Cselect+id%3D%22catid%22+name%3D%22catid%22%3E%0A++++++++++++++++%3Coption+value%3D%220%22%3E-+Selecionar+categoria+-%3C%2Foption%3E%0A++++++++++++++++%3Coption+style%3D%22color%3A+rgb%28128%2C+128%2C+128%29%3B%22+value%3D%221%22+disabled%3D%22disabled%22%3ENot%C3%ADcias%3C%2Foption%3E%0A++++++++++++++++%3Coption+style%3D%22color%3A+rgb%28128%2C+128%2C+128%29%3B%22+value%3D%222%22+disabled%3D%22disabled%22%3E-+-+-+Estado%3C%2Foption%3E%0A++++++++++++++++%3Coption+style%3D%22color%3A+rgb%28128%2C+128%2C+128%29%3B%22+value%3D%2229%22+disabled%3D%22disabled%22%3E-+-+-+Cultura%3C%2Foption%3E%0A++++++++++++++++%3Coption+style%3D%22color%3A+rgb%28128%2C+128%2C+128%29%3B%22+value%3D%2241%22+disabled%3D%22disabled%22%3E-+-+-+Nacional%3C%2Foption%3E%0A++++++++++++++++%3Coption+style%3D%22color%3A+rgb%28128%2C+128%2C+128%29%3B%22+value%3D%225%22+disabled%3D%22disabled%22%3EColunas%3C%2Foption%3E%0A++++++++++++++++%3Coption+style%3D%22color%3A+rgb%28128%2C+128%2C+128%29%3B%22+value%3D%226%22+disabled%3D%22disabled%22%3E-+-+-+Trocando+em+mi%C3%BAdos%3C%2Foption%3E%0A++++++++++++++++%3Coption+style%3D%22color%3A+rgb%28128%2C+128%2C+128%29%3B%22+value%3D%227%22+disabled%3D%22disabled%22%3E-+-+-+Colunistas%3C%2Foption%3E%0A++++++++++++++++%3Coption+style%3D%22color%3A+rgb%28128%2C+128%2C+128%29%3B%22+value%3D%2224%22+disabled%3D%22disabled%22%3E-+-+-+-+-+Tecnologia%3C%2Foption%3E%0A++++++++++++++++%3Coption+value%3D%2210%22+selected%3D%22selected%22%3EClassificados%3C%2Foption%3E%0A++++++++++++++++%3Coption+value%3D%2230%22%3E-+-+-+Im%C3%B3veis%3C%2Foption%3E%0A++++++++++++++++%3Coption+value%3D%2233%22%3E-+-+-+-+-+Venda%3C%2Foption%3E%0A++++++++++++++++%3Coption+style%3D%22color%3A+rgb%28128%2C+128%2C+128%29%3B%22+value%3D%2216%22+disabled%3D%22disabled%22%3EJur%C3%ADdica%3C%2Foption%3E%0A++++++++++++++++%3Coption+style%3D%22color%3A+rgb%28128%2C+128%2C+128%29%3B%22+value%3D%2226%22+disabled%3D%22disabled%22%3EAtividade+parlamentar%3C%2Foption%3E%0A++++++++++++++++%3Coption+style%3D%22color%3A+rgb%28128%2C+128%2C+128%29%3B%22+value%3D%2238%22+disabled%3D%22disabled%22%3E-+-+-+ACOMPANHE+A+COBERTURA+DO+IMPEACHMENT%3C%2Foption%3E%0A++++++++++++++++%3Coption+style%3D%22color%3A+rgb%28128%2C+128%2C+128%29%3B%22+value%3D%2239%22+disabled%3D%22disabled%22%3EESPECIAL%3C%2Foption%3E%0A++++++++++++++++%3Coption+style%3D%22color%3A+rgb%28128%2C+128%2C+128%29%3B%22+value%3D%2240%22+disabled%3D%22disabled%22%3E-+-+-+ACOMPANHE+A+COBERTURA+DO+IMPEACHMENT%3C%2Foption%3E%0A++++++++++++%3C%2Fselect%3E%0A++++++++%3C%2Ftd%3E%0A++++%3C%2Ftr%3E%0A%3C%2Ftable%3E'
   33     1        INIT_FCALL                                               'libxml_use_internal_errors'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                                 
   34     4        NEW                                              $9      'DOMDocument'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $9
   35     7        INIT_METHOD_CALL                                         !1, 'loadHTML'
          8        SEND_VAR_EX                                              !0
          9        SEND_VAL_EX                                              8196
         10        DO_FCALL                                      0          
   36    11        NEW                                              $13     'DOMXPath'
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !2, $13
   37    15        INIT_METHOD_CALL                                         !2, 'query'
         16        SEND_VAL_EX                                              '%2F%2Foption%5B%40disabled%5D'
         17        DO_FCALL                                      0  $16     
         18        ASSIGN                                                   !3, $16
   38    19        FETCH_OBJ_R                                      ~18     !3, 'length'
         20        ASSIGN                                                   !4, ~18
         21      > JMP                                                      ->36
   39    22    >   INIT_METHOD_CALL                                         !3, 'item'
         23        SEND_VAR_EX                                              !4
         24        DO_FCALL                                      0  $20     
         25        ASSIGN                                                   !5, $20
   40    26        FETCH_OBJ_R                                      ~22     !5, 'nextSibling'
         27        ASSIGN                                                   !6, ~22
   41    28        FETCH_OBJ_R                                      ~24     !5, 'parentNode'
         29        INIT_METHOD_CALL                                         ~24, 'removeChild'
         30        SEND_VAR_EX                                              !5
         31        DO_FCALL                                      0          
   42    32        FETCH_OBJ_R                                      ~26     !6, 'parentNode'
         33        INIT_METHOD_CALL                                         ~26, 'removeChild'
         34        SEND_VAR_EX                                              !6
         35        DO_FCALL                                      0          
   38    36    >   PRE_DEC                                          ~28     !4
         37        IS_SMALLER_OR_EQUAL                                      0, ~28
         38      > JMPNZ                                                    ~29, ->22
   45    39    >   INIT_METHOD_CALL                                         !1, 'saveHTML'
         40        DO_FCALL                                      0  $30     
         41        ECHO                                                     $30
         42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
194.69 ms | 1400 KiB | 15 Q