3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<'EOD' aaa <a href="link.php?x=banana">text 1</a> bbb <a href="different_url.php">text 2</a> ccc <a href="link.php?x=orange">text 3</a> ddd EOD; $dom = new DOMDocument; $dom->loadHTML('<div id="root">' . $html . '</div>'); $nodeList = $dom->getElementsByTagName('a'); foreach($nodeList as $link) { $query = parse_url($link->getAttribute('href'), PHP_URL_QUERY); if ( !$query ) continue; parse_str($query, $arr); if ( isset($arr['x']) ) $link->parentNode->insertBefore($dom->createTextNode($arr['x'] . ' '), $link); } $result = ''; foreach($dom->getElementById('root')->childNodes as $childNode) { $result .= $dom->saveHTML($childNode); } echo $result;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 43
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 43
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 26
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 42
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 42
Branch analysis from position: 43
2 jumps found. (Code = 77) Position 1 = 50, Position 2 = 56
Branch analysis from position: 50
2 jumps found. (Code = 78) Position 1 = 51, Position 2 = 56
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
Branch analysis from position: 43
filename:       /in/99tkc
function name:  (null)
number of ops:  59
compiled vars:  !0 = $html, !1 = $dom, !2 = $nodeList, !3 = $link, !4 = $query, !5 = $arr, !6 = $result, !7 = $childNode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'aaa%0A%3Ca+href%3D%22link.php%3Fx%3Dbanana%22%3Etext+1%3C%2Fa%3E%0Abbb%0A%3Ca+href%3D%22different_url.php%22%3Etext+2%3C%2Fa%3E%0Accc%0A%3Ca+href%3D%22link.php%3Fx%3Dorange%22%3Etext+3%3C%2Fa%3E%0Addd'
   13     1        NEW                                              $9      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $9
   14     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        CONCAT                                           ~12     '%3Cdiv+id%3D%22root%22%3E', !0
          6        CONCAT                                           ~13     ~12, '%3C%2Fdiv%3E'
          7        SEND_VAL_EX                                              ~13
          8        DO_FCALL                                      0          
   15     9        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         10        SEND_VAL_EX                                              'a'
         11        DO_FCALL                                      0  $15     
         12        ASSIGN                                                   !2, $15
   17    13      > FE_RESET_R                                       $17     !2, ->43
         14    > > FE_FETCH_R                                               $17, !3, ->43
   18    15    >   INIT_FCALL                                               'parse_url'
         16        INIT_METHOD_CALL                                         !3, 'getAttribute'
         17        SEND_VAL_EX                                              'href'
         18        DO_FCALL                                      0  $18     
         19        SEND_VAR                                                 $18
         20        SEND_VAL                                                 6
         21        DO_ICALL                                         $19     
         22        ASSIGN                                                   !4, $19
   19    23        BOOL_NOT                                         ~21     !4
         24      > JMPZ                                                     ~21, ->26
         25    > > JMP                                                      ->14
   20    26    >   INIT_FCALL                                               'parse_str'
         27        SEND_VAR                                                 !4
         28        SEND_REF                                                 !5
         29        DO_ICALL                                                 
   21    30        ISSET_ISEMPTY_DIM_OBJ                         0          !5, 'x'
         31      > JMPZ                                                     ~23, ->42
   22    32    >   FETCH_OBJ_R                                      ~24     !3, 'parentNode'
         33        INIT_METHOD_CALL                                         ~24, 'insertBefore'
         34        INIT_METHOD_CALL                                         !1, 'createTextNode'
         35        FETCH_DIM_R                                      ~25     !5, 'x'
         36        CONCAT                                           ~26     ~25, '+'
         37        SEND_VAL_EX                                              ~26
         38        DO_FCALL                                      0  $27     
         39        SEND_VAR_NO_REF_EX                                       $27
         40        SEND_VAR_EX                                              !3
         41        DO_FCALL                                      0          
   17    42    > > JMP                                                      ->14
         43    >   FE_FREE                                                  $17
   25    44        ASSIGN                                                   !6, ''
   27    45        INIT_METHOD_CALL                                         !1, 'getElementById'
         46        SEND_VAL_EX                                              'root'
         47        DO_FCALL                                      0  $30     
         48        FETCH_OBJ_R                                      ~31     $30, 'childNodes'
         49      > FE_RESET_R                                       $32     ~31, ->56
         50    > > FE_FETCH_R                                               $32, !7, ->56
   28    51    >   INIT_METHOD_CALL                                         !1, 'saveHTML'
         52        SEND_VAR_EX                                              !7
         53        DO_FCALL                                      0  $33     
         54        ASSIGN_OP                                     8          !6, $33
   27    55      > JMP                                                      ->50
         56    >   FE_FREE                                                  $32
   31    57        ECHO                                                     !6
         58      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.65 ms | 1004 KiB | 15 Q