3v4l.org

run code in 500+ PHP versions simultaneously
<?php $html = <<<'__HTML' <html xmlns:v="urn:schemas-microsoft-com:vml"... other xmlns> <head> <meta tags, title, styles, a couple comments too (they are irrelevant to the question)> </head> <body lang=EN-US link=blue vlink=purple style='tab-interval:36.0pt'> <div class=WordSection1> <h1>Pros and Cons of a Website</h1> <p class=MsoBodyText align=left style='a long irrelevant list'><span style='long list'><o:p>&nbsp;</o:p></span></p>(this is a sample of what it uses as line breaks. Take note of the <o:p> tag). <p class=MsoBodyText style='margin-right:5.75pt;line-height:115%'> A<span style='letter-spacing:.05pt'> </span>SAMPLE<span style='letter-spacing:.05pt'> </span>TEXT </p> </div> <div class=WordSection2>...same pattern in div 1</div> <div class=WordSection3>...same...</div> </body> </html><html xmlns:v="urn:schemas-microsoft-com:vml"... other xmlns> <head> <meta tags, title, styles, a couple comments too (they are irrelevant to the question)> </head> <body lang=EN-US link=blue vlink=purple style='tab-interval:36.0pt'> <div class=WordSection1> <h1>Pros and Cons of a Website</h1> <p class=MsoBodyText align=left style='a long irrelevant list'><span style='long list'><o:p>&nbsp;</o:p></span></p>(this is a sample of what it uses as line breaks. Take note of the <o:p> tag). <p class=MsoBodyText style='margin-right:5.75pt;line-height:115%'> A<span style='letter-spacing:.05pt'> </span>SAMPLE<span style='letter-spacing:.05pt'> </span>TEXT </p> </div> <div class=WordSection2>...same pattern in div 1</div> <div class=WordSection3>...same...</div> </body> </html> __HTML; libxml_use_internal_errors(true); $doc = new DomDocument(); $doc->loadHTML($html); foreach ($doc->getElementsByTagName('div') as $div) { $raw = $div->textContent; $text = trim(preg_replace('/\s+/', ' ', $raw)); var_dump($text); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 25
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 25
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/VpIEq
function name:  (null)
number of ops:  27
compiled vars:  !0 = $html, !1 = $doc, !2 = $div, !3 = $raw, !4 = $text
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%3Chtml+xmlns%3Av%3D%22urn%3Aschemas-microsoft-com%3Avml%22...+other+xmlns%3E%0A++++%3Chead%3E%0A++++++++%3Cmeta+tags%2C+title%2C+styles%2C+a+couple+comments+too+%28they+are+irrelevant+to+the+question%29%3E%0A++++%3C%2Fhead%3E%0A++++%3Cbody+lang%3DEN-US+link%3Dblue+vlink%3Dpurple+style%3D%27tab-interval%3A36.0pt%27%3E%0A++++++++%3Cdiv+class%3DWordSection1%3E%0A++++++++++++%3Ch1%3EPros+and+Cons+of+a+Website%3C%2Fh1%3E%0A++++++++++++%3Cp+class%3DMsoBodyText+align%3Dleft+style%3D%27a+long+irrelevant+list%27%3E%3Cspan+style%3D%27long+list%27%3E%3Co%3Ap%3E%26nbsp%3B%3C%2Fo%3Ap%3E%3C%2Fspan%3E%3C%2Fp%3E%28this+is+a+sample+of+what+it+uses+as+line+breaks.+Take+note+of+the+%3Co%3Ap%3E+tag%29.%0A++++++++++++%3Cp+class%3DMsoBodyText+style%3D%27margin-right%3A5.75pt%3Bline-height%3A115%25%27%3E%0A++++A%3Cspan+style%3D%27letter-spacing%3A.05pt%27%3E+%3C%2Fspan%3ESAMPLE%3Cspan+style%3D%27letter-spacing%3A.05pt%27%3E+%3C%2Fspan%3ETEXT%0A++++++++++++%3C%2Fp%3E%0A++++++++%3C%2Fdiv%3E%0A++++++++%3Cdiv+class%3DWordSection2%3E...same+pattern+in+div+1%3C%2Fdiv%3E%0A++++++++%3Cdiv+class%3DWordSection3%3E...same...%3C%2Fdiv%3E%0A+++%3C%2Fbody%3E%0A%3C%2Fhtml%3E%3Chtml+xmlns%3Av%3D%22urn%3Aschemas-microsoft-com%3Avml%22...+other+xmlns%3E%0A++++%3Chead%3E%0A++++++++%3Cmeta+tags%2C+title%2C+styles%2C+a+couple+comments+too+%28they+are+irrelevant+to+the+question%29%3E%0A++++%3C%2Fhead%3E%0A++++%3Cbody+lang%3DEN-US+link%3Dblue+vlink%3Dpurple+style%3D%27tab-interval%3A36.0pt%27%3E%0A++++++++%3Cdiv+class%3DWordSection1%3E%0A++++++++++++%3Ch1%3EPros+and+Cons+of+a+Website%3C%2Fh1%3E%0A++++++++++++%3Cp+class%3DMsoBodyText+align%3Dleft+style%3D%27a+long+irrelevant+list%27%3E%3Cspan+style%3D%27long+list%27%3E%3Co%3Ap%3E%26nbsp%3B%3C%2Fo%3Ap%3E%3C%2Fspan%3E%3C%2Fp%3E%28this+is+a+sample+of+what+it+uses+as+line+breaks.+Take+note+of+the+%3Co%3Ap%3E+tag%29.%0A++++++++++++%3Cp+class%3DMsoBodyText+style%3D%27margin-right%3A5.75pt%3Bline-height%3A115%25%27%3E%0A++++A%3Cspan+style%3D%27letter-spacing%3A.05pt%27%3E+%3C%2Fspan%3ESAMPLE%3Cspan+style%3D%27letter-spacing%3A.05pt%27%3E+%3C%2Fspan%3ETEXT%0A++++++++++++%3C%2Fp%3E%0A++++++++%3C%2Fdiv%3E%0A++++++++%3Cdiv+class%3DWordSection2%3E...same+pattern+in+div+1%3C%2Fdiv%3E%0A++++++++%3Cdiv+class%3DWordSection3%3E...same...%3C%2Fdiv%3E%0A+++%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   37     1        INIT_FCALL                                                   'libxml_use_internal_errors'
          2        SEND_VAL                                                     <true>
          3        DO_ICALL                                                     
   38     4        NEW                                                  $7      'DomDocument'
          5        DO_FCALL                                          0          
          6        ASSIGN                                                       !1, $7
   39     7        INIT_METHOD_CALL                                             !1, 'loadHTML'
          8        SEND_VAR_EX                                                  !0
          9        DO_FCALL                                          0          
   40    10        INIT_METHOD_CALL                                             !1, 'getElementsByTagName'
         11        SEND_VAL_EX                                                  'div'
         12        DO_FCALL                                          0  $11     
         13      > FE_RESET_R                                           $12     $11, ->25
         14    > > FE_FETCH_R                                                   $12, !2, ->25
   41    15    >   FETCH_OBJ_R                                          ~13     !2, 'textContent'
         16        ASSIGN                                                       !3, ~13
   42    17        FRAMELESS_ICALL_3                preg_replace        ~15     '%2F%5Cs%2B%2F', '+'
         18        OP_DATA                                                      !3
         19        FRAMELESS_ICALL_1                trim                ~16     ~15
         20        ASSIGN                                                       !4, ~16
   43    21        INIT_FCALL                                                   'var_dump'
         22        SEND_VAR                                                     !4
         23        DO_ICALL                                                     
   40    24      > JMP                                                          ->14
         25    >   FE_FREE                                                      $12
   44    26      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.31 ms | 1503 KiB | 15 Q