3v4l.org

run code in 500+ PHP versions simultaneously
<?php $html = "<div>this outer <a href='#'>first link</a> is the best <span>destination</span></div><a href='#'>second link</a>"; $doc = new DOMDocument(); $doc->loadHTML($html); $links = $doc->getElementsByTagName('a'); foreach($links as $link) { echo $doc->saveHTML($link) . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 19
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/rMUH1
function name:  (null)
number of ops:  21
compiled vars:  !0 = $html, !1 = $doc, !2 = $links, !3 = $link
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, '%3Cdiv%3Ethis+outer+%3Ca+href%3D%27%23%27%3Efirst+link%3C%2Fa%3E+is+the+best+%3Cspan%3Edestination%3C%2Fspan%3E%3C%2Fdiv%3E%3Ca+href%3D%27%23%27%3Esecond+link%3C%2Fa%3E'
    3     1        NEW                                                  $5      'DOMDocument'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $5
    4     4        INIT_METHOD_CALL                                             !1, 'loadHTML'
          5        SEND_VAR_EX                                                  !0
          6        DO_FCALL                                          0          
    5     7        INIT_METHOD_CALL                                             !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                                  'a'
          9        DO_FCALL                                          0  $9      
         10        ASSIGN                                                       !2, $9
    6    11      > FE_RESET_R                                           $11     !2, ->19
         12    > > FE_FETCH_R                                                   $11, !3, ->19
    7    13    >   INIT_METHOD_CALL                                             !1, 'saveHTML'
         14        SEND_VAR_EX                                                  !3
         15        DO_FCALL                                          0  $12     
         16        CONCAT                                               ~13     $12, '%0A'
         17        ECHO                                                         ~13
    6    18      > JMP                                                          ->12
         19    >   FE_FREE                                                      $11
    8    20      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
223.2 ms | 2613 KiB | 13 Q