3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = <<<str <a href="https://www.domainurl.com/refer/google-adsense/">fsdf</a> <a title="Google Adsense" href="https://www.domainurl.com/refer/google-adsense/" target="_blank" rel="nofollow noopener">fgddf</a> <a href="https://www.domainurl.com/page/pago">domain </a> <a title="Google Adsense" href="https://www.googlead.com/refer/google-adsense/" target="_blank" rel="nofollow noopener">googled</a> str; $domainToRemove = 'domainurl.com'; $dom = new DOMDocument; $dom->loadHTML("<div>{$str}</div>", LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $anchors = $dom->getElementsByTagName('a'); // Code taken and modified from: http://php.net/manual/en/domnode.replacechild.php#50500 $i = $anchors->length - 1; while ($i > -1) { $anchor = $anchors->item($i); if (strpos($anchor->getAttribute('href'), $domainToRemove) !== false) { // $new = $dom->createElement('p', $anchor->textContent); $new = $dom->createTextNode($anchor->textContent); $anchor->parentNode->replaceChild($new, $anchor); } $i--; } // Create HTML string, then remove the wrapping div. $html = $dom->saveHTML(); $html = substr($html, 5, strlen($html) - 7 - 5); echo $html;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 20
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 44
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 20
Branch analysis from position: 47
Branch analysis from position: 20
Branch analysis from position: 44
filename:       /in/aUt7X
function name:  (null)
number of ops:  61
compiled vars:  !0 = $str, !1 = $domainToRemove, !2 = $dom, !3 = $anchors, !4 = $i, !5 = $anchor, !6 = $new, !7 = $html
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '+++++%3Ca+href%3D%22https%3A%2F%2Fwww.domainurl.com%2Frefer%2Fgoogle-adsense%2F%22%3Efsdf%3C%2Fa%3E%0A++++%3Ca+title%3D%22Google+Adsense%22+href%3D%22https%3A%2F%2Fwww.domainurl.com%2Frefer%2Fgoogle-adsense%2F%22+target%3D%22_blank%22+rel%3D%22nofollow+noopener%22%3Efgddf%3C%2Fa%3E%0A++++%3Ca+href%3D%22https%3A%2F%2Fwww.domainurl.com%2Fpage%2Fpago%22%3Edomain+%3C%2Fa%3E%0A%3Ca+title%3D%22Google+Adsense%22+href%3D%22https%3A%2F%2Fwww.googlead.com%2Frefer%2Fgoogle-adsense%2F%22+target%3D%22_blank%22+rel%3D%22nofollow+noopener%22%3Egoogled%3C%2Fa%3E'
   10     1        ASSIGN                                                   !1, 'domainurl.com'
   12     2        NEW                                              $10     'DOMDocument'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !2, $10
   13     5        INIT_METHOD_CALL                                         !2, 'loadHTML'
          6        ROPE_INIT                                     3  ~14     '%3Cdiv%3E'
          7        ROPE_ADD                                      1  ~14     ~14, !0
          8        ROPE_END                                      2  ~13     ~14, '%3C%2Fdiv%3E'
          9        SEND_VAL_EX                                              ~13
         10        SEND_VAL_EX                                              8196
         11        DO_FCALL                                      0          
   15    12        INIT_METHOD_CALL                                         !2, 'getElementsByTagName'
         13        SEND_VAL_EX                                              'a'
         14        DO_FCALL                                      0  $17     
         15        ASSIGN                                                   !3, $17
   17    16        FETCH_OBJ_R                                      ~19     !3, 'length'
         17        SUB                                              ~20     ~19, 1
         18        ASSIGN                                                   !4, ~20
   18    19      > JMP                                                      ->45
   19    20    >   INIT_METHOD_CALL                                         !3, 'item'
         21        SEND_VAR_EX                                              !4
         22        DO_FCALL                                      0  $22     
         23        ASSIGN                                                   !5, $22
   21    24        INIT_FCALL                                               'strpos'
         25        INIT_METHOD_CALL                                         !5, 'getAttribute'
         26        SEND_VAL_EX                                              'href'
         27        DO_FCALL                                      0  $24     
         28        SEND_VAR                                                 $24
         29        SEND_VAR                                                 !1
         30        DO_ICALL                                         $25     
         31        TYPE_CHECK                                  1018          $25
         32      > JMPZ                                                     ~26, ->44
   23    33    >   INIT_METHOD_CALL                                         !2, 'createTextNode'
         34        CHECK_FUNC_ARG                                           
         35        FETCH_OBJ_FUNC_ARG                               $27     !5, 'textContent'
         36        SEND_FUNC_ARG                                            $27
         37        DO_FCALL                                      0  $28     
         38        ASSIGN                                                   !6, $28
   25    39        FETCH_OBJ_R                                      ~30     !5, 'parentNode'
         40        INIT_METHOD_CALL                                         ~30, 'replaceChild'
         41        SEND_VAR_EX                                              !6
         42        SEND_VAR_EX                                              !5
         43        DO_FCALL                                      0          
   28    44    >   PRE_DEC                                                  !4
   18    45    >   IS_SMALLER                                               -1, !4
         46      > JMPNZ                                                    ~33, ->20
   32    47    >   INIT_METHOD_CALL                                         !2, 'saveHTML'
         48        DO_FCALL                                      0  $34     
         49        ASSIGN                                                   !7, $34
   33    50        INIT_FCALL                                               'substr'
         51        SEND_VAR                                                 !7
         52        SEND_VAL                                                 5
         53        STRLEN                                           ~36     !7
         54        SUB                                              ~37     ~36, 7
         55        SUB                                              ~38     ~37, 5
         56        SEND_VAL                                                 ~38
         57        DO_ICALL                                         $39     
         58        ASSIGN                                                   !7, $39
   34    59        ECHO                                                     !7
   35    60      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.26 ms | 1011 KiB | 15 Q