3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <p><iframe allowfullscreen="" class="media-element file-default" data-fid="2219" data-media-element="1" frameborder="0" height="360" src="https://www.youtube.com/embed/sNEJOm4hSaw?feature=oembed" width="640"></iframe></p> HTML; $dom = new DOMDocument; $dom->loadHTML($html); foreach ($dom->getElementsByTagName('iframe') as $iframe) { $a = $dom->createElement('a'); $a->setAttribute('href', $iframe->getAttribute('src')); $a->nodeValue = "Link to youtube"; $iframe->parentNode->replaceChild($a, $iframe); } echo $dom->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 31
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 31
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/840NG
function name:  (null)
number of ops:  36
compiled vars:  !0 = $html, !1 = $dom, !2 = $iframe, !3 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cp%3E%3Ciframe+allowfullscreen%3D%22%22+class%3D%22media-element+file-default%22+data-fid%3D%222219%22+data-media-element%3D%221%22+frameborder%3D%220%22+height%3D%22360%22+src%3D%22https%3A%2F%2Fwww.youtube.com%2Fembed%2FsNEJOm4hSaw%3Ffeature%3Doembed%22+width%3D%22640%22%3E%3C%2Fiframe%3E%3C%2Fp%3E'
    6     1        NEW                                              $5      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
    7     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
    8     7        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                              'iframe'
          9        DO_FCALL                                      0  $9      
         10      > FE_RESET_R                                       $10     $9, ->31
         11    > > FE_FETCH_R                                               $10, !2, ->31
    9    12    >   INIT_METHOD_CALL                                         !1, 'createElement'
         13        SEND_VAL_EX                                              'a'
         14        DO_FCALL                                      0  $11     
         15        ASSIGN                                                   !3, $11
   10    16        INIT_METHOD_CALL                                         !3, 'setAttribute'
         17        SEND_VAL_EX                                              'href'
         18        INIT_METHOD_CALL                                         !2, 'getAttribute'
         19        SEND_VAL_EX                                              'src'
         20        DO_FCALL                                      0  $13     
         21        SEND_VAR_NO_REF_EX                                       $13
         22        DO_FCALL                                      0          
   11    23        ASSIGN_OBJ                                               !3, 'nodeValue'
         24        OP_DATA                                                  'Link+to+youtube'
   12    25        FETCH_OBJ_R                                      ~16     !2, 'parentNode'
         26        INIT_METHOD_CALL                                         ~16, 'replaceChild'
         27        SEND_VAR_EX                                              !3
         28        SEND_VAR_EX                                              !2
         29        DO_FCALL                                      0          
    8    30      > JMP                                                      ->11
         31    >   FE_FREE                                                  $10
   14    32        INIT_METHOD_CALL                                         !1, 'saveHTML'
         33        DO_FCALL                                      0  $18     
         34        ECHO                                                     $18
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.9 ms | 1399 KiB | 13 Q