3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<'XML' <root> <main> <article> <p> The stunning increase in homelessness announced in Los Angeles this week — up 16% over last year citywide — was an almost an incomprehensible conundrum given the nation's booming economy and the hundreds of millions of dollars that city, county and state officials have directed toward the problem. </p> <p> "We cannot let a set of difficult numbers discourage us or weaken our resolve" Garcetti said. </p> <p> For more information: Maeve Reston, CNN </p> </article> </main> </root> XML; $document = new DOMDocument(); $document->loadXML($xml); $xpath = new DOMXpath($document); $expression = "//p[starts-with(normalize-space(), 'Reference')]/preceding-sibling::p | //p[starts-with(normalize-space(), 'For more')]/preceding-sibling::p | //p[starts-with(normalize-space(), 'Something')]/preceding-sibling::p"; foreach ($xpath->evaluate($expression) as $node) { echo $document->saveXML($node); } $expression = "//p[ starts-with(normalize-space(), 'Reference') or starts-with(normalize-space(), 'For more') or starts-with(normalize-space(), 'Something') ]/preceding-sibling::p"; foreach ($xpath->evaluate($expression) as $node) { echo $document->saveXML($node); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 22
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 34
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 22
filename:       /in/9SMJq
function name:  (null)
number of ops:  36
compiled vars:  !0 = $xml, !1 = $document, !2 = $xpath, !3 = $expression, !4 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Croot%3E%0A++++%3Cmain%3E%0A++++++++%3Carticle%3E%0A++++++++++++%3Cp%3E%0A+++++++++++++++The+stunning+increase+in+homelessness+announced+in+Los+Angeles+%0A+++++++++++++++this+week+%E2%80%94+up+16%25+over+last+year+citywide+%E2%80%94+was+an+almost++an+%0A+++++++++++++++incomprehensible+conundrum+given+the+nation%27s+booming+economy+%0A+++++++++++++++and+the+hundreds+of+millions+of+dollars+that+city%2C+county+and+%0A+++++++++++++++state+officials+have+directed+toward+the+problem.%0A++++++++++++%3C%2Fp%3E%0A++++++++++++%3Cp%3E%0A++++++++++++++++%22We+cannot+let+a+set+of+difficult+numbers+discourage+us+%0A++++++++++++++++or+weaken+our+resolve%22+Garcetti+said.%0A++++++++++++%3C%2Fp%3E%0A++++++++++++%3Cp%3E%0A++++++++++++++++For+more+information%3A+Maeve+Reston%2C+CNN%0A++++++++++++%3C%2Fp%3E%0A++++++++%3C%2Farticle%3E%0A++++%3C%2Fmain%3E%0A%3C%2Froot%3E'
   26     1        NEW                                              $6      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
   27     4        INIT_METHOD_CALL                                         !1, 'loadXML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   28     7        NEW                                              $10     'DOMXpath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $10
   30    11        ASSIGN                                                   !3, '%2F%2Fp%5Bstarts-with%28normalize-space%28%29%2C+%27Reference%27%29%5D%2Fpreceding-sibling%3A%3Ap+%7C+%0A+++++%2F%2Fp%5Bstarts-with%28normalize-space%28%29%2C+%27For+more%27%29%5D%2Fpreceding-sibling%3A%3Ap+%7C+%0A+++++%2F%2Fp%5Bstarts-with%28normalize-space%28%29%2C+%27Something%27%29%5D%2Fpreceding-sibling%3A%3Ap'
   35    12        INIT_METHOD_CALL                                         !2, 'evaluate'
         13        SEND_VAR_EX                                              !3
         14        DO_FCALL                                      0  $14     
         15      > FE_RESET_R                                       $15     $14, ->22
         16    > > FE_FETCH_R                                               $15, !4, ->22
   36    17    >   INIT_METHOD_CALL                                         !1, 'saveXML'
         18        SEND_VAR_EX                                              !4
         19        DO_FCALL                                      0  $16     
         20        ECHO                                                     $16
   35    21      > JMP                                                      ->16
         22    >   FE_FREE                                                  $15
   39    23        ASSIGN                                                   !3, '%2F%2Fp%5B%0A++++++starts-with%28normalize-space%28%29%2C+%27Reference%27%29+or+%0A++++++starts-with%28normalize-space%28%29%2C+%27For+more%27%29+or+%0A++++++starts-with%28normalize-space%28%29%2C+%27Something%27%29%0A++++%5D%2Fpreceding-sibling%3A%3Ap'
   46    24        INIT_METHOD_CALL                                         !2, 'evaluate'
         25        SEND_VAR_EX                                              !3
         26        DO_FCALL                                      0  $18     
         27      > FE_RESET_R                                       $19     $18, ->34
         28    > > FE_FETCH_R                                               $19, !4, ->34
   47    29    >   INIT_METHOD_CALL                                         !1, 'saveXML'
         30        SEND_VAR_EX                                              !4
         31        DO_FCALL                                      0  $20     
         32        ECHO                                                     $20
   46    33      > JMP                                                      ->28
         34    >   FE_FREE                                                  $19
   48    35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.56 ms | 1012 KiB | 13 Q