3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = "<p> Some text here </p> <p> Some other text here </p> <h1> Title 1 </h1> <p> Another text here </p> <p> Some random text here </p> <h1> Title 2 </h1> <p> Some text here </p> <p> Some other text here </p> <h1>..<h1>"; $dom = new DOMDocument(); $dom->loadHTML($html); foreach ($dom->getElementsByTagName('*') as $element){ if ($element->tagName == "h1") $element->textContent = "Is h1"; if ($element->tagName == "p") $element->textContent = "Is p"; } $html = $dom->saveHTML(); echo $html;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 22
Branch analysis from position: 17
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/jfeqe
function name:  (null)
number of ops:  29
compiled vars:  !0 = $html, !1 = $dom, !2 = $element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cp%3E+Some+text+here+%3C%2Fp%3E%0A%3Cp%3E+Some+other+text+here+%3C%2Fp%3E%0A%3Ch1%3E+Title+1+%3C%2Fh1%3E%0A%3Cp%3E+Another+text+here+%3C%2Fp%3E%0A%3Cp%3E+Some+random+text+here+%3C%2Fp%3E%0A%3Ch1%3E+Title+2+%3C%2Fh1%3E%0A%3Cp%3E+Some+text+here+%3C%2Fp%3E%0A%3Cp%3E+Some+other+text+here+%3C%2Fp%3E%0A%3Ch1%3E..%3Ch1%3E'
   12     1        NEW                                              $4      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $4
   13     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   14     7        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                              '%2A'
          9        DO_FCALL                                      0  $8      
         10      > FE_RESET_R                                       $9      $8, ->23
         11    > > FE_FETCH_R                                               $9, !2, ->23
   15    12    >   FETCH_OBJ_R                                      ~10     !2, 'tagName'
         13        IS_EQUAL                                                 ~10, 'h1'
         14      > JMPZ                                                     ~11, ->17
   16    15    >   ASSIGN_OBJ                                               !2, 'textContent'
         16        OP_DATA                                                  'Is+h1'
   17    17    >   FETCH_OBJ_R                                      ~13     !2, 'tagName'
         18        IS_EQUAL                                                 ~13, 'p'
         19      > JMPZ                                                     ~14, ->22
   18    20    >   ASSIGN_OBJ                                               !2, 'textContent'
         21        OP_DATA                                                  'Is+p'
   14    22    > > JMP                                                      ->11
         23    >   FE_FREE                                                  $9
   20    24        INIT_METHOD_CALL                                         !1, 'saveHTML'
         25        DO_FCALL                                      0  $16     
         26        ASSIGN                                                   !0, $16
   21    27        ECHO                                                     !0
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.81 ms | 996 KiB | 13 Q