3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = ' <div> <p>Lorem Ipsum1</p> <p>Lorem Ipsum2</p> <h2>Title</h2> <p>Lorem Ipsum3</p><!-- PHP gets this paragraph --> <p>Lorem Ipsum4</p> <h2>Title</h2> <p>Lorem Ipsum5</p> </div>'; $xml = simplexml_load_string($str); $headings = $xml->xpath('h2'); $contents = []; foreach ($headings as $heading) { $contents[] = (string)$heading->xpath('following-sibling::p')[0]; } var_dump($contents);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/LUuHG
function name:  (null)
number of ops:  25
compiled vars:  !0 = $str, !1 = $xml, !2 = $headings, !3 = $contents, !4 = $heading
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%0A%3Cdiv%3E%0A++++%3Cp%3ELorem+Ipsum1%3C%2Fp%3E%0A++++%3Cp%3ELorem+Ipsum2%3C%2Fp%3E%0A%0A++++%3Ch2%3ETitle%3C%2Fh2%3E%0A++++%3Cp%3ELorem+Ipsum3%3C%2Fp%3E%3C%21--+PHP+gets+this+paragraph+--%3E%0A++++%3Cp%3ELorem+Ipsum4%3C%2Fp%3E%0A%0A++++%3Ch2%3ETitle%3C%2Fh2%3E%0A++++%3Cp%3ELorem+Ipsum5%3C%2Fp%3E%0A%3C%2Fdiv%3E'
   16     1        INIT_FCALL                                               'simplexml_load_string'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $6      
          4        ASSIGN                                                   !1, $6
   17     5        INIT_METHOD_CALL                                         !1, 'xpath'
          6        SEND_VAL_EX                                              'h2'
          7        DO_FCALL                                      0  $8      
          8        ASSIGN                                                   !2, $8
   19     9        ASSIGN                                                   !3, <array>
   20    10      > FE_RESET_R                                       $11     !2, ->20
         11    > > FE_FETCH_R                                               $11, !4, ->20
   21    12    >   INIT_METHOD_CALL                                         !4, 'xpath'
         13        SEND_VAL_EX                                              'following-sibling%3A%3Ap'
         14        DO_FCALL                                      0  $13     
         15        FETCH_DIM_R                                      ~14     $13, 0
         16        CAST                                          6  ~15     ~14
         17        ASSIGN_DIM                                               !3
         18        OP_DATA                                                  ~15
   20    19      > JMP                                                      ->11
         20    >   FE_FREE                                                  $11
   24    21        INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !3
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
292.72 ms | 1012 KiB | 15 Q