3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = <<<DATA <a href="fruit.html">The Apple red</a> <a href="Construction.html#one">The big Home</a> <a href="automotive.html?lang=en">Car for rent</a> <a href="fruit.html">The Pineapple red</a> <a href="Construction.html#one">The biggest Home</a> <a href="automotive.html?lang=en">Cars for rent</a> DATA; $dom = new DOMDocument(); $dom->loadHTML($data); foreach($dom->getElementsByTagName("a") as $element) { if (preg_match('#\b(?:apple|big|car)\b#i', $element->nodeValue)) { echo $element->getAttribute("href") . PHP_EOL; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 24
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 24
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 23
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/p3AOG
function name:  (null)
number of ops:  26
compiled vars:  !0 = $data, !1 = $dom, !2 = $element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Ca+href%3D%22fruit.html%22%3EThe+Apple+red%3C%2Fa%3E%0A%3Ca+href%3D%22Construction.html%23one%22%3EThe+big+Home%3C%2Fa%3E%0A%3Ca+href%3D%22automotive.html%3Flang%3Den%22%3ECar+for+rent%3C%2Fa%3E%0A%3Ca+href%3D%22fruit.html%22%3EThe+Pineapple+red%3C%2Fa%3E%0A%3Ca+href%3D%22Construction.html%23one%22%3EThe+biggest+Home%3C%2Fa%3E%0A%3Ca+href%3D%22automotive.html%3Flang%3Den%22%3ECars+for+rent%3C%2Fa%3E'
   12     1        NEW                                              $4      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $4
   13     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   15     7        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                              'a'
          9        DO_FCALL                                      0  $8      
         10      > FE_RESET_R                                       $9      $8, ->24
         11    > > FE_FETCH_R                                               $9, !2, ->24
   16    12    >   INIT_FCALL                                               'preg_match'
         13        SEND_VAL                                                 '%23%5Cb%28%3F%3Aapple%7Cbig%7Ccar%29%5Cb%23i'
         14        FETCH_OBJ_R                                      ~10     !2, 'nodeValue'
         15        SEND_VAL                                                 ~10
         16        DO_ICALL                                         $11     
         17      > JMPZ                                                     $11, ->23
   17    18    >   INIT_METHOD_CALL                                         !2, 'getAttribute'
         19        SEND_VAL_EX                                              'href'
         20        DO_FCALL                                      0  $12     
         21        CONCAT                                           ~13     $12, '%0A'
         22        ECHO                                                     ~13
   15    23    > > JMP                                                      ->11
         24    >   FE_FREE                                                  $9
   19    25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.75 ms | 1011 KiB | 14 Q