3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = <<<DATA <img title="How to" alt="How to" src="windows_en.jpg" loading="lazy" width="1280" height="720" class="img-first"> DATA; $dom = new DOMDocument(); $dom->loadHTML($data, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); foreach($dom->getElementsByTagName("img") as $elm) { foreach($elm->attributes as $att) { if ($att->name !== "src" && $att->name !== "alt") { $elm->removeAttribute($att->name); } } } echo $dom->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 31
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 31
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 29
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 29
Branch analysis from position: 16
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 28
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 28
Branch analysis from position: 22
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 29
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/C9kFU
function name:  (null)
number of ops:  36
compiled vars:  !0 = $data, !1 = $dom, !2 = $elm, !3 = $att
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cimg+title%3D%22How+to%22+alt%3D%22How+to%22+src%3D%22windows_en.jpg%22+loading%3D%22lazy%22+width%3D%221280%22+height%3D%22720%22+class%3D%22img-first%22%3E'
    7     1        NEW                                              $5      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
    8     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              8196
          7        DO_FCALL                                      0          
    9     8        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          9        SEND_VAL_EX                                              'img'
         10        DO_FCALL                                      0  $9      
         11      > FE_RESET_R                                       $10     $9, ->31
         12    > > FE_FETCH_R                                               $10, !2, ->31
   10    13    >   FETCH_OBJ_R                                      ~11     !2, 'attributes'
         14      > FE_RESET_R                                       $12     ~11, ->29
         15    > > FE_FETCH_R                                               $12, !3, ->29
   11    16    >   FETCH_OBJ_R                                      ~13     !3, 'name'
         17        IS_NOT_IDENTICAL                                 ~14     ~13, 'src'
         18      > JMPZ_EX                                          ~14     ~14, ->22
         19    >   FETCH_OBJ_R                                      ~15     !3, 'name'
         20        IS_NOT_IDENTICAL                                 ~16     ~15, 'alt'
         21        BOOL                                             ~14     ~16
         22    > > JMPZ                                                     ~14, ->28
   12    23    >   INIT_METHOD_CALL                                         !2, 'removeAttribute'
         24        CHECK_FUNC_ARG                                           
         25        FETCH_OBJ_FUNC_ARG                               $17     !3, 'name'
         26        SEND_FUNC_ARG                                            $17
         27        DO_FCALL                                      0          
   10    28    > > JMP                                                      ->15
         29    >   FE_FREE                                                  $12
    9    30      > JMP                                                      ->12
         31    >   FE_FREE                                                  $10
   17    32        INIT_METHOD_CALL                                         !1, 'saveHTML'
         33        DO_FCALL                                      0  $19     
         34        ECHO                                                     $19
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.28 ms | 1012 KiB | 13 Q