3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <p class="Heading1-P"> <span class="Heading1-H">Chapter 1</span> </p> <p class="Normal-P"> <span class="Normal-H">This is chapter 1</span> </p> <p class="Heading1-P"> <span class="Heading1-H">Chapter 2</span> </p> <p class="Normal-P"> <span class="Normal-H">This is chapter 2</span> </p> <p class="Heading1-P"> <span class="Heading1-H">Chapter 3</span> </p> <p class="Normal-P"> <span class="Normal-H">This is chapter 3</span> </p> HTML; $dom = new DOMDocument(); $dom->loadHTML($html); $xpath = new DOMXPath($dom); foreach (['Heading1-H', 'Normal-H'] as $class) { var_export( array_column( iterator_to_array($xpath->query("//*[@class='$class']/text()")), 'nodeValue' ) ); echo "\n---\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 31
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 31
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/k78pR
function name:  (null)
number of ops:  33
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath, !3 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cp+class%3D%22Heading1-P%22%3E%0A++++%3Cspan+class%3D%22Heading1-H%22%3EChapter+1%3C%2Fspan%3E%0A%3C%2Fp%3E%0A%3Cp+class%3D%22Normal-P%22%3E%0A++++%3Cspan+class%3D%22Normal-H%22%3EThis+is+chapter+1%3C%2Fspan%3E%0A%3C%2Fp%3E%0A%3Cp+class%3D%22Heading1-P%22%3E%0A++++%3Cspan+class%3D%22Heading1-H%22%3EChapter+2%3C%2Fspan%3E%0A%3C%2Fp%3E%0A%3Cp+class%3D%22Normal-P%22%3E%0A++++%3Cspan+class%3D%22Normal-H%22%3EThis+is+chapter+2%3C%2Fspan%3E%0A%3C%2Fp%3E%0A%3Cp+class%3D%22Heading1-P%22%3E%0A++++%3Cspan+class%3D%22Heading1-H%22%3EChapter+3%3C%2Fspan%3E%0A%3C%2Fp%3E%0A%3Cp+class%3D%22Normal-P%22%3E%0A++++%3Cspan+class%3D%22Normal-H%22%3EThis+is+chapter+3%3C%2Fspan%3E%0A%3C%2Fp%3E'
   24     1        NEW                                              $5      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
   25     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   26     7        NEW                                              $9      'DOMXPath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $9
   27    11      > FE_RESET_R                                       $12     <array>, ->31
         12    > > FE_FETCH_R                                               $12, !3, ->31
   28    13    >   INIT_FCALL                                               'var_export'
   29    14        INIT_FCALL                                               'array_column'
   30    15        INIT_FCALL                                               'iterator_to_array'
         16        INIT_METHOD_CALL                                         !2, 'query'
         17        ROPE_INIT                                     3  ~14     '%2F%2F%2A%5B%40class%3D%27'
         18        ROPE_ADD                                      1  ~14     ~14, !3
         19        ROPE_END                                      2  ~13     ~14, '%27%5D%2Ftext%28%29'
         20        SEND_VAL_EX                                              ~13
         21        DO_FCALL                                      0  $16     
         22        SEND_VAR                                                 $16
         23        DO_ICALL                                         $17     
         24        SEND_VAR                                                 $17
   31    25        SEND_VAL                                                 'nodeValue'
   29    26        DO_ICALL                                         $18     
   31    27        SEND_VAR                                                 $18
   28    28        DO_ICALL                                                 
   34    29        ECHO                                                     '%0A---%0A'
   27    30      > JMP                                                      ->12
         31    >   FE_FREE                                                  $12
   35    32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156 ms | 1017 KiB | 16 Q