3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '<a href="page1.html#num0035583725">name1</a> <a href="page30.html#num0035584494">othername</a> <a href="page55.html#num0035584859">word</a> <a href="page132.html#num0035585496">wordname</a> <a href="page133.html#num0035586039">datadata</a> <a href="page203.html#num0035586647">fsdfasfas</a>'; $doc = new DOMDocument('1.0', 'utf-8'); libxml_use_internal_errors(true); $doc->LoadHTML($string, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $links = $doc->getElementsByTagName('a'); foreach($links as $link){ if(strpos($link->nodeValue, 'name1') !== FALSE) { $href = $link->getAttribute('href'); preg_match('/#\K.+/', $href, $fragment); echo $fragment[0]; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 38
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 38
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 37
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
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/F5LND
function name:  (null)
number of ops:  40
compiled vars:  !0 = $string, !1 = $doc, !2 = $links, !3 = $link, !4 = $href, !5 = $fragment
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Ca+href%3D%22page1.html%23num0035583725%22%3Ename1%3C%2Fa%3E%0A%3Ca+href%3D%22page30.html%23num0035584494%22%3Eothername%3C%2Fa%3E%0A%3Ca+href%3D%22page55.html%23num0035584859%22%3Eword%3C%2Fa%3E%0A%3Ca+href%3D%22page132.html%23num0035585496%22%3Ewordname%3C%2Fa%3E%0A%3Ca+href%3D%22page133.html%23num0035586039%22%3Edatadata%3C%2Fa%3E%0A%3Ca+href%3D%22page203.html%23num0035586647%22%3Efsdfasfas%3C%2Fa%3E'
    8     1        NEW                                              $7      'DOMDocument'
          2        SEND_VAL_EX                                              '1.0'
          3        SEND_VAL_EX                                              'utf-8'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $7
    9     6        INIT_FCALL                                               'libxml_use_internal_errors'
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                                 
   10     9        INIT_METHOD_CALL                                         !1, 'LoadHTML'
         10        SEND_VAR_EX                                              !0
         11        SEND_VAL_EX                                              8196
         12        DO_FCALL                                      0          
   11    13        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         14        SEND_VAL_EX                                              'a'
         15        DO_FCALL                                      0  $12     
         16        ASSIGN                                                   !2, $12
   12    17      > FE_RESET_R                                       $14     !2, ->38
         18    > > FE_FETCH_R                                               $14, !3, ->38
   13    19    >   INIT_FCALL                                               'strpos'
         20        FETCH_OBJ_R                                      ~15     !3, 'nodeValue'
         21        SEND_VAL                                                 ~15
         22        SEND_VAL                                                 'name1'
         23        DO_ICALL                                         $16     
         24        TYPE_CHECK                                  1018          $16
         25      > JMPZ                                                     ~17, ->37
   14    26    >   INIT_METHOD_CALL                                         !3, 'getAttribute'
         27        SEND_VAL_EX                                              'href'
         28        DO_FCALL                                      0  $18     
         29        ASSIGN                                                   !4, $18
   15    30        INIT_FCALL                                               'preg_match'
         31        SEND_VAL                                                 '%2F%23%5CK.%2B%2F'
         32        SEND_VAR                                                 !4
         33        SEND_REF                                                 !5
         34        DO_ICALL                                                 
   16    35        FETCH_DIM_R                                      ~21     !5, 0
         36        ECHO                                                     ~21
   12    37    > > JMP                                                      ->18
         38    >   FE_FREE                                                  $14
   18    39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.64 ms | 1017 KiB | 16 Q