3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <html> <head> <title>Urls</title> </head> <body> <a href="https://www.google.com">Google</a> <a href="https://facebook.com">Facebook</a> <a href="http://www.example.com">Example</a> <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <h1>Heading</h1> <a href="www.example.com">Example</a> </body> </html> HTML; $dom = new DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($html); $xpath = new DOMXPath($dom); $result = []; foreach ($xpath->query("//@href") as $href) { $noQueryString = explode('?', $href->nodeValue, 2)[0]; if (strpos($noQueryString, 'www.example.com') !== false) { $result[] = $href->nodeValue; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 38
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 38
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 37
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 37
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/UgRT5
function name:  (null)
number of ops:  43
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath, !3 = $result, !4 = $href, !5 = $noQueryString
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Chtml%3E%0A%3Chead%3E%0A++++%3Ctitle%3EUrls%3C%2Ftitle%3E%0A%3C%2Fhead%3E%0A%3Cbody%3E%0A++++%3Ca+href%3D%22https%3A%2F%2Fwww.google.com%22%3EGoogle%3C%2Fa%3E%0A++++%3Ca+href%3D%22https%3A%2F%2Ffacebook.com%22%3EFacebook%3C%2Fa%3E%0A++++%3Ca+href%3D%22http%3A%2F%2Fwww.example.com%22%3EExample%3C%2Fa%3E%0A%0A++++%3Cp%3EDuis+aute+irure+dolor+in+reprehenderit+in+voluptate+velit+esse%0A++++cillum+dolore+eu+fugiat+nulla+pariatur.+Excepteur+sint+occaecat+cupidatat+non%0A++++proident%2C+sunt+in+culpa+qui+officia+deserunt+mollit+anim+id+est+laborum.%3C%2Fp%3E%0A%0A++++%3Ch1%3EHeading%3C%2Fh1%3E%0A%0A++++%3Ca+href%3D%22www.example.com%22%3EExample%3C%2Fa%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   24     1        NEW                                              $7      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
   25     4        INIT_FCALL                                               'libxml_use_internal_errors'
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                                 
   26     7        INIT_METHOD_CALL                                         !1, 'loadHTML'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   27    10        NEW                                              $12     'DOMXPath'
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !2, $12
   29    14        ASSIGN                                                   !3, <array>
   30    15        INIT_METHOD_CALL                                         !2, 'query'
         16        SEND_VAL_EX                                              '%2F%2F%40href'
         17        DO_FCALL                                      0  $16     
         18      > FE_RESET_R                                       $17     $16, ->38
         19    > > FE_FETCH_R                                               $17, !4, ->38
   31    20    >   INIT_FCALL                                               'explode'
         21        SEND_VAL                                                 '%3F'
         22        FETCH_OBJ_R                                      ~18     !4, 'nodeValue'
         23        SEND_VAL                                                 ~18
         24        SEND_VAL                                                 2
         25        DO_ICALL                                         $19     
         26        FETCH_DIM_R                                      ~20     $19, 0
         27        ASSIGN                                                   !5, ~20
   32    28        INIT_FCALL                                               'strpos'
         29        SEND_VAR                                                 !5
         30        SEND_VAL                                                 'www.example.com'
         31        DO_ICALL                                         $22     
         32        TYPE_CHECK                                  1018          $22
         33      > JMPZ                                                     ~23, ->37
   33    34    >   FETCH_OBJ_R                                      ~25     !4, 'nodeValue'
         35        ASSIGN_DIM                                               !3
         36        OP_DATA                                                  ~25
   30    37    > > JMP                                                      ->19
         38    >   FE_FREE                                                  $17
   36    39        INIT_FCALL                                               'var_export'
         40        SEND_VAR                                                 !3
         41        DO_ICALL                                                 
         42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.78 ms | 1013 KiB | 17 Q