3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = <<<DATA <texts> <text> <paragraph/> First text <paragraph/> Second text </text> <text> <paragraph/> Third text <paragraph/> Fourth text </text> </texts> DATA; $doc = new DOMDocument(); $doc->loadXML($data); $xpath = new DOMXpath($doc); $i = 1; $expression = "//text/text()"; foreach ($xpath->query($expression) as $text) { $result = trim($text->nodeValue); if ($result !== "") { echo sprintf("%d | %s<br>", $i++, $result); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 33
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 33
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 32
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 32
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/lPDP3
function name:  (null)
number of ops:  35
compiled vars:  !0 = $data, !1 = $doc, !2 = $xpath, !3 = $i, !4 = $expression, !5 = $text, !6 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Ctexts%3E%0A%3Ctext%3E%0A++%3Cparagraph%2F%3E%0A++++First+text%0A++%3Cparagraph%2F%3E%0A++++Second+text%0A%3C%2Ftext%3E%0A%3Ctext%3E%0A++%3Cparagraph%2F%3E%0A++++Third+text%0A++%3Cparagraph%2F%3E%0A++++Fourth+text%0A%3C%2Ftext%3E%0A%3C%2Ftexts%3E'
   19     1        NEW                                              $8      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $8
   20     4        INIT_METHOD_CALL                                         !1, 'loadXML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   21     7        NEW                                              $12     'DOMXpath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $12
   22    11        ASSIGN                                                   !3, 1
   23    12        ASSIGN                                                   !4, '%2F%2Ftext%2Ftext%28%29'
   24    13        INIT_METHOD_CALL                                         !2, 'query'
         14        SEND_VAR_EX                                              !4
         15        DO_FCALL                                      0  $17     
         16      > FE_RESET_R                                       $18     $17, ->33
         17    > > FE_FETCH_R                                               $18, !5, ->33
   25    18    >   INIT_FCALL                                               'trim'
         19        FETCH_OBJ_R                                      ~19     !5, 'nodeValue'
         20        SEND_VAL                                                 ~19
         21        DO_ICALL                                         $20     
         22        ASSIGN                                                   !6, $20
   26    23        IS_NOT_IDENTICAL                                         !6, ''
         24      > JMPZ                                                     ~22, ->32
   27    25    >   INIT_FCALL                                               'sprintf'
         26        SEND_VAL                                                 '%25d+%7C+%25s%3Cbr%3E'
         27        POST_INC                                         ~23     !3
         28        SEND_VAL                                                 ~23
         29        SEND_VAR                                                 !6
         30        DO_ICALL                                         $24     
         31        ECHO                                                     $24
   24    32    > > JMP                                                      ->17
         33    >   FE_FREE                                                  $18
   29    34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.23 ms | 1439 KiB | 15 Q