3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = <<<DATA This is a link <a href="https://stackoverflow.com/">SO</a> and this is <a href="http://test.test">unsubscribe</a> and another and this is <a href="http://test.test">UnSubScribe</a>. DATA; $dom = new DomDocument(); $dom->loadHTML($data); $xpath = new DOMXPath($dom); $query = "//a[contains(translate(., 'UNSUBSCRIBE', 'unsubscribe'),'unsubscribe')]"; $anchors = $xpath->query($query); foreach ($anchors as $a) { echo sprintf("%s: %s" . PHP_EOL, $a->nodeValue, $a->getAttribute("href") ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 29
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 29
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/X95nt
function name:  (null)
number of ops:  31
compiled vars:  !0 = $data, !1 = $dom, !2 = $xpath, !3 = $query, !4 = $anchors, !5 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'This+is+a+link+%3Ca+href%3D%22https%3A%2F%2Fstackoverflow.com%2F%22%3ESO%3C%2Fa%3E+and+this+is+%3Ca+href%3D%22http%3A%2F%2Ftest.test%22%3Eunsubscribe%3C%2Fa%3E+and+%0Aanother+and+this+is+%3Ca+href%3D%22http%3A%2F%2Ftest.test%22%3EUnSubScribe%3C%2Fa%3E.'
    8     1        NEW                                              $7      'DomDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
    9     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   10     7        NEW                                              $11     'DOMXPath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $11
   11    11        ASSIGN                                                   !3, '%2F%2Fa%5Bcontains%28translate%28.%2C+%27UNSUBSCRIBE%27%2C+%27unsubscribe%27%29%2C%27unsubscribe%27%29%5D'
   12    12        INIT_METHOD_CALL                                         !2, 'query'
         13        SEND_VAR_EX                                              !3
         14        DO_FCALL                                      0  $15     
         15        ASSIGN                                                   !4, $15
   14    16      > FE_RESET_R                                       $17     !4, ->29
         17    > > FE_FETCH_R                                               $17, !5, ->29
   15    18    >   INIT_FCALL                                               'sprintf'
         19        SEND_VAL                                                 '%25s%3A+%25s%0A'
   16    20        FETCH_OBJ_R                                      ~18     !5, 'nodeValue'
         21        SEND_VAL                                                 ~18
   17    22        INIT_METHOD_CALL                                         !5, 'getAttribute'
         23        SEND_VAL_EX                                              'href'
         24        DO_FCALL                                      0  $19     
         25        SEND_VAR                                                 $19
   15    26        DO_ICALL                                         $20     
   17    27        ECHO                                                     $20
   14    28      > JMP                                                      ->17
         29    >   FE_FREE                                                  $17
   19    30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.18 ms | 1006 KiB | 14 Q