3v4l.org

run code in 300+ PHP versions simultaneously
<?php $urlContent = '<li><span><a href="https://site1.com">site1.com</a> : Description 1</span></li> <li><span><a href="https://site2.com">site2.com</a> : Description 2</span></li> <li><span><a href="https://site3.com">site3.com</a> : Description 3</span></li> <li><span><a href="https://site4.com">site4.com</a> : Description 4</span></li>'; $dom = new DOMDocument(); @$dom->loadHTML($urlContent); $xpath = new DOMXPath($dom); $lis = $xpath->evaluate("/html/body/li"); //$li = document.getElementsByTagName("li"); foreach ($lis as $li) { $a = $xpath->evaluate("span/a", $li)->item(0); $url = $a->getAttribute('href'); var_dump($url, trim($a->nextSibling->nodeValue, ' :')); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 42
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 42
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/CYAoj
function name:  (null)
number of ops:  44
compiled vars:  !0 = $urlContent, !1 = $dom, !2 = $xpath, !3 = $lis, !4 = $li, !5 = $a, !6 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cli%3E%3Cspan%3E%3Ca+href%3D%22https%3A%2F%2Fsite1.com%22%3Esite1.com%3C%2Fa%3E+%3A+Description+1%3C%2Fspan%3E%3C%2Fli%3E%0A%3Cli%3E%3Cspan%3E%3Ca+href%3D%22https%3A%2F%2Fsite2.com%22%3Esite2.com%3C%2Fa%3E+%3A+Description+2%3C%2Fspan%3E%3C%2Fli%3E%0A%3Cli%3E%3Cspan%3E%3Ca+href%3D%22https%3A%2F%2Fsite3.com%22%3Esite3.com%3C%2Fa%3E+%3A+Description+3%3C%2Fspan%3E%3C%2Fli%3E%0A%3Cli%3E%3Cspan%3E%3Ca+href%3D%22https%3A%2F%2Fsite4.com%22%3Esite4.com%3C%2Fa%3E+%3A+Description+4%3C%2Fspan%3E%3C%2Fli%3E'
    8     1        NEW                                              $8      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $8
    9     4        BEGIN_SILENCE                                    ~11     
          5        INIT_METHOD_CALL                                         !1, 'loadHTML'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
          8        END_SILENCE                                              ~11
   10     9        NEW                                              $13     'DOMXPath'
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !2, $13
   11    13        INIT_METHOD_CALL                                         !2, 'evaluate'
         14        SEND_VAL_EX                                              '%2Fhtml%2Fbody%2Fli'
         15        DO_FCALL                                      0  $16     
         16        ASSIGN                                                   !3, $16
   14    17      > FE_RESET_R                                       $18     !3, ->42
         18    > > FE_FETCH_R                                               $18, !4, ->42
   15    19    >   INIT_METHOD_CALL                                         !2, 'evaluate'
         20        SEND_VAL_EX                                              'span%2Fa'
         21        SEND_VAR_EX                                              !4
         22        DO_FCALL                                      0  $19     
         23        INIT_METHOD_CALL                                         $19, 'item'
         24        SEND_VAL_EX                                              0
         25        DO_FCALL                                      0  $20     
         26        ASSIGN                                                   !5, $20
   16    27        INIT_METHOD_CALL                                         !5, 'getAttribute'
         28        SEND_VAL_EX                                              'href'
         29        DO_FCALL                                      0  $22     
         30        ASSIGN                                                   !6, $22
   17    31        INIT_FCALL                                               'var_dump'
         32        SEND_VAR                                                 !6
         33        INIT_FCALL                                               'trim'
         34        FETCH_OBJ_R                                      ~24     !5, 'nextSibling'
         35        FETCH_OBJ_R                                      ~25     ~24, 'nodeValue'
         36        SEND_VAL                                                 ~25
         37        SEND_VAL                                                 '+%3A'
         38        DO_ICALL                                         $26     
         39        SEND_VAR                                                 $26
         40        DO_ICALL                                                 
   14    41      > JMP                                                      ->18
         42    >   FE_FREE                                                  $18
   18    43      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.7 ms | 1011 KiB | 15 Q