3v4l.org

run code in 300+ PHP versions simultaneously
<?php //a URL you want to retrieve $my_url = 'http://www.digg.com'; $html = file_get_contents($my_url); $dom = new DOMDocument(); $dom->loadHTML($html); $xpath = new DOMXPath($dom); //Put your XPath Query here $my_xpath_query = "/html/body/div[@id='container']/div[@id='contents']/div[@class='list' and @id='wrapper']/div[@class='main' and position()=1]/div[contains(@class, 'news-summary')]/div[@class='news-body']/h3"; $result_rows = $xpath->query($my_xpath_query); //here we loop through our results (a DOMDocument Object) foreach ($result_rows as $result_object){ echo $result_object->childNodes->item(0)->nodeValue; } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 29
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 29
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/jaGkB
function name:  (null)
number of ops:  31
compiled vars:  !0 = $my_url, !1 = $html, !2 = $dom, !3 = $xpath, !4 = $my_xpath_query, !5 = $result_rows, !6 = $result_object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'http%3A%2F%2Fwww.digg.com'
    4     1        INIT_FCALL                                               'file_get_contents'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $8      
          4        ASSIGN                                                   !1, $8
    5     5        NEW                                              $10     'DOMDocument'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !2, $10
    6     8        INIT_METHOD_CALL                                         !2, 'loadHTML'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0          
    7    11        NEW                                              $14     'DOMXPath'
         12        SEND_VAR_EX                                              !2
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !3, $14
   10    15        ASSIGN                                                   !4, '%2Fhtml%2Fbody%2Fdiv%5B%40id%3D%27container%27%5D%2Fdiv%5B%40id%3D%27contents%27%5D%2Fdiv%5B%40class%3D%27list%27+and+%40id%3D%27wrapper%27%5D%2Fdiv%5B%40class%3D%27main%27+and+position%28%29%3D1%5D%2Fdiv%5Bcontains%28%40class%2C+%27news-summary%27%29%5D%2Fdiv%5B%40class%3D%27news-body%27%5D%2Fh3'
   11    16        INIT_METHOD_CALL                                         !3, 'query'
         17        SEND_VAR_EX                                              !4
         18        DO_FCALL                                      0  $18     
         19        ASSIGN                                                   !5, $18
   14    20      > FE_RESET_R                                       $20     !5, ->29
         21    > > FE_FETCH_R                                               $20, !6, ->29
   15    22    >   FETCH_OBJ_R                                      ~21     !6, 'childNodes'
         23        INIT_METHOD_CALL                                         ~21, 'item'
         24        SEND_VAL_EX                                              0
         25        DO_FCALL                                      0  $22     
         26        FETCH_OBJ_R                                      ~23     $22, 'nodeValue'
         27        ECHO                                                     ~23
   14    28      > JMP                                                      ->21
         29    >   FE_FREE                                                  $20
   17    30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.55 ms | 1396 KiB | 15 Q