3v4l.org

run code in 300+ PHP versions simultaneously
<?php $in = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head><title>...</title></head><body>abc<br /><br/>def<p>ghi<br />jkl</p></body></html>'; $doc = new DOMDOcument; $doc->loadhtml($in); $linebreak = $doc->createTextNode("\n"); foreach(iterator_to_array($doc->getElementsByTagName('br')) as $node) { $node->parentNode->replaceChild($linebreak->cloneNode(), $node); } echo $doc->savehtml();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 27
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/UiJ1m
function name:  (null)
number of ops:  32
compiled vars:  !0 = $in, !1 = $doc, !2 = $linebreak, !3 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3C%21DOCTYPE+HTML+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+HTML+4.01%2F%2FEN%22%0A%22http%3A%2F%2Fwww.w3.org%2FTR%2Fhtml4%2Fstrict.dtd%22%3E%0A%3Chtml%3E%3Chead%3E%3Ctitle%3E...%3C%2Ftitle%3E%3C%2Fhead%3E%3Cbody%3Eabc%3Cbr+%2F%3E%3Cbr%2F%3Edef%3Cp%3Eghi%3Cbr+%2F%3Ejkl%3C%2Fp%3E%3C%2Fbody%3E%3C%2Fhtml%3E'
    7     1        NEW                                              $5      'DOMDOcument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
    8     4        INIT_METHOD_CALL                                         !1, 'loadhtml'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   10     7        INIT_METHOD_CALL                                         !1, 'createTextNode'
          8        SEND_VAL_EX                                              '%0A'
          9        DO_FCALL                                      0  $9      
         10        ASSIGN                                                   !2, $9
   12    11        INIT_FCALL                                               'iterator_to_array'
         12        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         13        SEND_VAL_EX                                              'br'
         14        DO_FCALL                                      0  $11     
         15        SEND_VAR                                                 $11
         16        DO_ICALL                                         $12     
         17      > FE_RESET_R                                       $13     $12, ->27
         18    > > FE_FETCH_R                                               $13, !3, ->27
   13    19    >   FETCH_OBJ_R                                      ~14     !3, 'parentNode'
         20        INIT_METHOD_CALL                                         ~14, 'replaceChild'
         21        INIT_METHOD_CALL                                         !2, 'cloneNode'
         22        DO_FCALL                                      0  $15     
         23        SEND_VAR_NO_REF_EX                                       $15
         24        SEND_VAR_EX                                              !3
         25        DO_FCALL                                      0          
   12    26      > JMP                                                      ->18
         27    >   FE_FREE                                                  $13
   16    28        INIT_METHOD_CALL                                         !1, 'savehtml'
         29        DO_FCALL                                      0  $17     
         30        ECHO                                                     $17
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.34 ms | 1011 KiB | 14 Q