3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<!doctype html> <html> <head> <title>test</title> </head> <body> <a id="1"> <b>value1</b> <b>value2</b> </a> <a id="2"> <b>value1</b> </a> </body> </html>'; $doc = new DOMDocument(); $doc->loadHTML($html); $xpath = new DOMXpath($doc); $nodes = $xpath->query("//b[contains(., 'value1')] | //b[contains(., 'value2')]"); $parent_id = $nodes->item(0)->parentNode->getAttribute("id"); echo $parent_id;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s8smP
function name:  (null)
number of ops:  25
compiled vars:  !0 = $html, !1 = $doc, !2 = $xpath, !3 = $nodes, !4 = $parent_id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3C%21doctype+html%3E%0A%3Chtml%3E%0A%3Chead%3E%0A++++%3Ctitle%3Etest%3C%2Ftitle%3E%0A%3C%2Fhead%3E%0A%3Cbody%3E%0A++++%3Ca+id%3D%221%22%3E%0A++++++++%3Cb%3Evalue1%3C%2Fb%3E%0A++++++++%3Cb%3Evalue2%3C%2Fb%3E%0A++++%3C%2Fa%3E%0A++++%3Ca+id%3D%222%22%3E%0A++++++++%3Cb%3Evalue1%3C%2Fb%3E%0A++++%3C%2Fa%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   19     1        NEW                                              $6      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
   20     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   22     7        NEW                                              $10     'DOMXpath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $10
   23    11        INIT_METHOD_CALL                                         !2, 'query'
         12        SEND_VAL_EX                                              '%2F%2Fb%5Bcontains%28.%2C+%27value1%27%29%5D+%7C+%2F%2Fb%5Bcontains%28.%2C+%27value2%27%29%5D'
         13        DO_FCALL                                      0  $13     
         14        ASSIGN                                                   !3, $13
   24    15        INIT_METHOD_CALL                                         !3, 'item'
         16        SEND_VAL_EX                                              0
         17        DO_FCALL                                      0  $15     
         18        FETCH_OBJ_R                                      ~16     $15, 'parentNode'
         19        INIT_METHOD_CALL                                         ~16, 'getAttribute'
         20        SEND_VAL_EX                                              'id'
         21        DO_FCALL                                      0  $17     
         22        ASSIGN                                                   !4, $17
   26    23        ECHO                                                     !4
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.09 ms | 995 KiB | 13 Q